BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Special Edition by Bill Evjen, Scott Hanselman, Devin Rader, Farhan Muhammad, Srinivasa Sivakumar; ISBN: 9780470041789
You are currently viewing the BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
hi,
I have one class library project created, there is one class BaseUIController in that, I want to write Navigate() method in the class would work as good as Response.Redirect("URL")
Function declaration is:
public void NavigatePage(string URL)
{
}
Please tell me how can I implement it, because System.Web.UI is not avaliabe in class library type projects, so I can'nt use Response.Redirect(URL).
Please guide me.
From a good design perspective, you should let the class library simply return a value that you use to determine where to redirect to in the presentation layer (the .aspx pages). By letting the class library redirect users, you tie it to a web application, which limits its reuse possibilities.
That said, you can add a reference to System.Web in your class library. Then you access objects like Response and Session in the class library like this:
Hi Imar,
I tried using the system.web.httpcontext.current.response.redirect(" mypage.aspx"); in the class library... but in runtime, its specifying that the object is null and not set to an instance. any ideas??? what do i need to do as alternative.
I have the same issue as Red_October. I have a button and the code behind for the button is
HttpContext.Current.Response.Redirect("URL", false);
when click on the button, system give this error "Object reference not set to an instance of an object"
I have a SharePoint site http://moss2007
I have a page on this site call ViewMyStaff.aspx (this is just a blank webpart page). when the user clicks on the button, system should take me to http://moss2007/Pages/ViewMyStaff.aspx page. The form library is in the same site collection as this page
I have the same problem, in my case I am trying to do the redirect from a VB.Net module, here is the code:
Code:
Public Sub ShowEPSErrorPage(Optional ByVal strErrorMessage As String = gGenericErrorMessage,Optional ByVal strDetailedMessage As String = "")
HttpContext.Current.Session.Add(ErrorPage.SA_ERR_MESSAGE, strErrorMessage)
HttpContext.Current.Session.Add(ErrorPage.SA_DETAILS_MESSAGE, strDetailedMessage)
HttpContext.Current.Response.Redirect("/ErrorPage.aspx")
End Sub
I have System.Web imported and as I said this is in a module which is part of my web application.
When I debug this, sometimes the debugger will be able to evaluate HttpContext.Current and sometimes it would tell me "Unable to evaluate expression", but either way this throws an exception with a message "Unable to evaluate expression"!! the path is proper so I am not sure what am I missing or doing wrong?