« Previous Next »

Thread: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

Last post 07-12-2009 5:32 PM by steve schofield. 9 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (10 items)

Sort Posts:

  • 04-27-2009, 4:54 AM

    How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    Hi to all.

    I need to set my custom error pages for 401, 404, 403, 500 in IIS 5.x. For 404  error I can set URL to the appropriate error page, but for others I can set only File or Default. How can I set my custom aspx error pages for errors?

  • 04-27-2009, 10:46 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,209
    • IIS MVPs

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    Since this is for ASP.NET you can use the custom errors section of your web.config file.

    http://support.microsoft.com/kb/306355

  • 04-28-2009, 2:45 PM In reply to

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

     Thank's for reply. I know this method, but it works only for ASP.Net's resources, like *.aspx, *.ashx and so all. For example if user asks *.aspx page which has restricted access he will receive *.aspx error page for error 403 (if you are set it in web.config). When user tries to get, for example *html page with restricted access he will receive standart error page from IIS, such as IIS processes this type of resources and ASP.Net will not receive this request. Approach when I need to set aspnet_isapi.dll for every type of resources is not appropriate.

  • 04-28-2009, 3:12 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,209
    • IIS MVPs

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    Gotcha.  You asked in the ASP.NET forum so I figured that's how you wanted to handle everything.

    What happens if you use file?  Does the aspx still get served?

  • 04-29-2009, 3:40 AM In reply to

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    I set for 404 error custom error page as File, Path="%path to my site%/ErrorPage.aspx". Then I tried to get following page /MySite/qweqweqweqwe, which is not exists, this request must be served by IIS. In IE7 I receive following page

    The XML page cannot be displayed

    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


    A name was started with an invalid character. Error processing resource 'http://localhost/ClosingCalendar_Dev/qweqweqweqwe'...

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ErrorPage.aspx.cs" Inherits="MyProject.WebSite.ErrorP...

     

  • 05-03-2009, 10:48 PM In reply to

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    Hi,

    If you selected URL, the custom error URL must exist in the application pool that directs the request to the custom error URL. If the page your requested encounter  a 401 or 403 error,  the custom error page also encounter the same error. Then, there would be a  loop. Hence, you can set only File or Default for these specific errors.

    Since you set custom error page as File, the custom error page will be served as a static file.  In this scenario, the .aspx page was processed as an XML file. The workaround is set simple html file for the specific errors and set URL for the others.

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 05-04-2009, 3:35 AM In reply to

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

     Hi!

    Sorry for bit of silly question: if there are exist any ways to set *.aspx custom error pages in IIS?

  • 06-08-2009, 8:09 PM In reply to

    • chenQ
    • Not Ranked
    • Joined on 06-09-2009, 12:05 AM
    • Posts 1

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    Hi,

     Try to use the URL option for message type, and then specify the URL for where your asp.net pages are served. The asp.net page needs to be served in order to work. Hope this helps.

  • 07-12-2009, 5:11 PM In reply to

    • johnly
    • Not Ranked
    • Joined on 05-31-2008, 12:23 PM
    • Posts 6

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

     

    You can use the Application_Error event handler to trap errors occured in your application. Due to the event's application-wide scope, you can log of application error information or handle other application-level errors that may occur.

    The Application_Error event handler is specified in the Global.asax file of your application. For simplicity, the steps in this section create a new page in which to throw the exception, trap the error in the Application_Error event handler of the Global.asax file, and you can write the error to the event log and redirect to a custom error page.

    Send-BulkSMS

     

  • 07-12-2009, 5:32 PM In reply to

    Re: How to set custom error pages for 401, 403, 500 errors in IIS 5.x

    A) Either set the asp.net isapi to handle all extensions or

    B) Set the custom errors in IIS.

    http://www.orcsweb.com/articles/custom_errors_in_iis.aspx

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
Page 1 of 1 (10 items)
Microsoft Communities