In all my previous Custom Error posts Part 1, Part 2 and Part 3, I have configured a static file (.htm) for custom error. You can also configure a .asp or .aspx page for custom error. But remember you will see the custom error page for .htm or .asp pages only. Example, www.dotnetscraps.com/blah.htm or www.dotnetscraps.com/blah.asp will show the custom page but www.dotnetscraps.com/blah.aspx will still show the detailed error message. Today we will configure .net dynamic pages to show custom errors in IIS 7.5.
- Click on the Web Site (Default Web Site in our case)
- In Features View, double click on .NET Error Pages
- Click Add…
- Under Status Code: type 404
- type an Absolute URL: e.g.: www.dotnetscraps.com/custerr/404.aspx
- Click OK
- You can also set a default redirect to an error page for all status codes you haven’t explicitly configured
- Click on Edit Feature Settings…
- Under Absolute URL, type the URL e.g.: www.dotnetscraps.com/custerr/error.aspx
Please refer the article customErrors Element (ASP.NET Settings Schema) to learn more about .NET customErrors.
My web.config:
<system.web><customErrors defaultRedirect="www.dotnetscraps.com/custerr/error.aspx" mode="RemoteOnly"><error redirect="www.dotnetscraps.com/custerr/404.aspx" statusCode="404" /></customErrors></system.web>
Hope this helps,
Vivek Kumbhar
Quote of the day:
I spent a lot of money on booze, birds and fast cars. The rest I just squandered. - George Best