i am sry but the above link doesnt slove my problem
i have a link on my page which points to default5.aspx
but as default5.aspx does not exist on the server the Application_Error is invoked :
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("default.aspx");
}
which tansfers the user to default.aspx but shows default5.aspx in the address bar.
now if i use state bags like Session["sno"] = "new"; itshows the error that default.aspx is not found on the server.
if use customerrors in web.config then it does redirect to default.aspx but shows some asp error url in the address bar.
but i want to display default5.aspx in the address bar
but how??
When you use Server.Transfer the requested URL is displayed in the browser.
The reason is because the Server changes what ASPX page to display....
For example:
The user requests the requestedAspxPage.aspx :
The requestedAspxPage.aspx doesn't exist, so you call Server.Transfer(anotherAspxPage.aspx)
The Server uses anotherAspxPage.aspx instead of the requestedAspxPage.aspx.
Since the server handles this, the URL in the web browser is not changed.
Now, if you use Response.Redirect(anotherAspxPage.aspx), the server returns an HTML code indicating to the browser that it should request anotherAspxPage. The URL is changed and the browser requests the "anotherAspxPage" instead of the requestedAspxPage.
I would use Response.Redirect for "Page Not Found" (404) errors...because if the url still points to a page that doesn't exist, the next time the user does a postback another error will occur again.
You can Rewrite the URL if you want...
See
URL rewriting in ASP.NET for more information on the topic.
-Frinny