I want to redirect all url errors
The url I want to cath is ~/bla/foo
It should redirect to ~/error404.aspx
bla exists as a folder. foo does not exist.
I already set the webconfig to point to my error but I just doesn't work. I get this error:
Server Error in application /.
-------------------------------------------------- ------------------------开发者_如何转开发------
The source can not be found.
Description: HTTP 404. Perhaps you are looking for the source (or a dependency thereof) removed or is temporarily unavailable or has changed its name. Check the spelling of the URL.
Requested URL: / bla/foo.asox
I google translate this error cuz VS here is language specific.
What can I do to resolve this??? I want to point to ~/error404.aspx
You can also configure a custom 404 page in IIS (this example is IIS 6). That way request for any resource that doesn't exist will go to your custom error404.aspx page.
There's also a walk through here with screen shots here if that helps. This would be something you configure outside of your application.
If you want to change the 404 message to a custom one, here are the steps to override the default one:
You can use:
protected void Application_Error(object sender, EventArgs e)
{
}
http://aspnetresources.com/articles/CustomErrorPages.aspx
There are more details in the link which show you exactly how to catch the 404 error and handle it.
精彩评论