Did you know: Enable Custom Error (.NET Error Pages) in IIS 7.5 - Part 4

by Vivek 12/23/2009 9:33:00 PM

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.

  1. Click on the Web Site (Default Web Site in our case)
  2. In Features View, double click on .NET Error Pages
  3. Click Add…
  4. Under Status Code: type 404
  5. type an Absolute URL: e.g.: www.dotnetscraps.com/custerr/404.aspx
  6. Click OK 

      image17
  7. You can also set a default redirect to an error page for all status codes you haven’t explicitly configured
  8. Click on Edit Feature Settings…
  9. Under Absolute URL, type the URL e.g.: www.dotnetscraps.com/custerr/error.aspx 

    image18

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



blog comments powered by Disqus

Rahul Soni

Rahul Soni  Twitter

 LinkedIn

 Facebook

 Email me



Vivek Kumbhar

Vivek Kumbhar  Twitter

 LinkedIn

 Facebook

 Email me


Stack Exchange

profile for Vivek at Server Fault, Q&A for system administrators and IT professionals

profile for Rahul Soni at Stack Overflow, Q&A for professional and enthusiast programmers

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

All Items
Sign in

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Rahul Soni

Powered by BlogEngine.NET 1.4.5.0