URL Mappings
Custom ASP.NET Error Pages
Custom Non-ASP.NET Error Pages (HTML, ASP,..)
- Open web.config file. (see MSDN)
- Create new urlMappings section within the system.web section.
- <urlMappings enabled="true">
<add url="~/contactus.aspx" mappedUrl="~/index.aspx" />
</urlMappings>
- If user types contactus.aspx, page mapped to the index.aspx.
- This approach won't work if you have 100 of pages to map.
- Best solution is to use regular expressions, but ASP.NET does not support. SEE
URL Rewriting
Custom ASP.NET Error Pages
- Open web.config file. (see MSDN)
- Modify/Create the <customErrors> section within the system.web section.
- <customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="404" redirect="FileNotFound.htm" />
<error statusCode="403" redirect="~/errors/NoAccess.htm" />
</customErrors> - redirect url may be relative(~/errors/PageNotFount.aspx) or absolute (http://makdns.blogspot.com/errors/PageNotFount.aspx)
- ~ point to the root of your web application
Custom Non-ASP.NET Error Pages (HTML, ASP,..)
- Open the Internet Services Manager.
- Expand your Default Web Site.
- Right-click and select Properties.
- Click the Custom Errors tab.
- Scroll down and highlight the 404 HTTP error and click Edit Properties.
- Change Message Type to URL.
- Enter the URL to "/FileNotFound.aspx".
- Click OK.
No comments:
Post a Comment