Previous Next

Thread: Default error page not working

Last post 08-08-2008 6:22 AM by diholaiis. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 08-04-2008, 5:45 AM

    • diholaiis
    • Top 150 Contributor
    • Joined on 06-25-2008, 10:50 AM
    • Posts 21
    • diholaiis

    Default error page not working

     Hi,

    I have a website running  on IIS7, integrated mode. I want to configure all HTTP errors to go to an aspx page. To do this I set up "Detailed errors for local requests and custom for remote", set the PATH parameter to "/Public/Error.aspx" and then tried all options, redirect/file/execute url, butI still get the default IIS messages for errors such as 404 when testing remotely.

    Can anybody point what I'm missing?

     

    Thanks

  • 08-04-2008, 11:48 AM In reply to

    • ksingla
    • Top 25 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 411
    • ksingla

    Re: Default error page not working

    Are you getting default error message for local or remote requests? If you are getting for remote, did you delete all the custom errors configured in httpErrors section? If there is no custom error configured, only then section level settings are effective.

    Thanks,
    Kj

  • 08-05-2008, 4:31 AM In reply to

    • diholaiis
    • Top 150 Contributor
    • Joined on 06-25-2008, 10:50 AM
    • Posts 21
    • diholaiis

    Re: Default error page not working

     Hi,

    I get them for both remote and local. I have deleted all error settings in IISm but I still get standard 404 error rather than the redirection to  my error page.

     

    Any ideas?

     

    Thanks a lot

  • 08-07-2008, 2:08 AM In reply to

    • ksingla
    • Top 25 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 411
    • ksingla

    Re: Default error page not working

    Can you pls paste your httpErrors configuration? You can use the following command to get the configuration as seen for the request which is generating 404.

    %windir%\system32\inetsrv\appcmd.exe list config http://localhost/error.htm /section:httpErrors

    Thanks,
    Kj

  • 08-07-2008, 4:39 AM In reply to

    • diholaiis
    • Top 150 Contributor
    • Joined on 06-25-2008, 10:50 AM
    • Posts 21
    • diholaiis

    Re: Default error page not working

     This is what I have in web.config:

           <customErrors mode="RemoteOnly" defaultRedirect="/Public/Error.aspx">
                <error statusCode="401" redirect="/Public/Error.aspx?http=401" />       
                <error statusCode="403" redirect="/Public/Error.aspx?http=403" />       
                <error statusCode="404" redirect="/Public/Error.aspx?http=404" />       
                <error statusCode="405" redirect="/Public/Error.aspx?http=405" />       
                <error statusCode="406" redirect="/Public/Error.aspx?http=406" />       
                <error statusCode="408" redirect="/Public/Error.aspx?http=408" />       
                <error statusCode="409" redirect="/Public/Error.aspx?http=409" />       
                <error statusCode="412" redirect="/Public/Error.aspx?http=412" />       
                <error statusCode="413" redirect="/Public/Error.aspx?http=413" />       
                <error statusCode="414" redirect="/Public/Error.aspx?http=414" />       
                <error statusCode="415" redirect="/Public/Error.aspx?http=415" />       
                <error statusCode="500" redirect="/Public/Error.aspx?http=500" />       
                <error statusCode="501" redirect="/Public/Error.aspx?http=501" />       
                <error statusCode="502" redirect="/Public/Error.aspx?http=502" /> 
                <error statusCode="503" redirect="/Public/Error.aspx?http=503" />       
                <error statusCode="504" redirect="/Public/Error.aspx?http=504" />       
                <error statusCode="505" redirect="/Public/Error.aspx?http=505" /> 
            </customErrors>

    Now it traps most 404 errors but I still get the IIS error occasionally . For example when I get a 404 error, the custom setting will redirect the request to
    http://www.....com/Public/Error.aspx?http=404 showing me the 404 page, but if I then mess about with that url, say
    http://www.....com/Public/ErrLALALALAor.aspx?http=404 then I see the IIS screen rather than
    my own 404 page.

     

    Same happens with 401, when I'm trying to access a secure page without logging in, I get redirected to the login page like:
    http://www.....com/Login.aspx?ReturnUrl=%2fproducts.aspx

    If I then mess about with the url, say
    http://www.....com/LoLALALALAgin.aspx?ReturnUrl=%2fproducts.aspx then I get the IIS error for 401.

    Perhaps the url redirection rules that I have in place are causing this?

                <rules>
                    <clear />
                    <rule name="Remove WWW" enabled="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^www\.([.a-zA-Z0-9]+)$" />
                        </conditions>
                        <action type="Redirect" url="https://{C:1}/{R:1}" appendQueryString="true" redirectType="Permanent" />
                    </rule>
                    <rule name="Force HTTPS" enabled="true">
                        <match url="(.*)" ignoreCase="false" />
                        <conditions>
                            <add input="{HTTPS}" pattern="off" />
                        </conditions>
                        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />
                    </rule>
             </rules>

     

    Thanks for your help

     

     

     

     

     

  • 08-08-2008, 2:07 AM In reply to

    • ksingla
    • Top 25 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 411
    • ksingla

    Re: Default error page not working

    Any particular reason to use asp.net custom errors rather than IIS custom errors? Doesn't seem like your redirect rules are causing any problem with custom errors. You can use FREB to find exactly what is happening but I would rather recommend ditching asp.net custom errors and using IIS custom errors itself. Your IIS custom errors section will look like following.

    <httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace" defaultResponseMode="ExecuteURL" defaultPath="/Public/Error.aspx">
       <clear/>
      <error statusCode="401" responseMode="ExecuteURL" path="/Public/Error.aspx?http=401" />
      <error ...
    </httpErrors>

  • 08-08-2008, 6:22 AM In reply to

    • diholaiis
    • Top 150 Contributor
    • Joined on 06-25-2008, 10:50 AM
    • Posts 21
    • diholaiis

    Re: Default error page not working

     Hi,

    This is what I now have in ApplicationHost.config:

     
        <location path="mysite">
            <system.webServer>

    <httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace" defaultResponseMode="ExecuteURL" defaultPath="/Public/Error.aspx">
       <clear/>
      <error statusCode="401" responseMode="ExecuteURL" path="/Public/Error.aspx?http=401" />
      <error statusCode="404" responseMode="ExecuteURL" path="/Public/Error.aspx?http=404" />
      <error statusCode="500" responseMode="ExecuteURL" path="/Public/Error.aspx?http=500" />

    </httpErrors>

      With or without this in web.config

     <customErrors mode="RemoteOnly" defaultRedirect="/Public/Error.aspx"/>

     it seems that ASP.NET is still trapping the errors. When I force a 401 I get the error page ASP.NET would give saying that detailed errors are not enabled remotely.

    If I go back and set these in web.config:

            <customErrors mode="RemoteOnly" defaultRedirect="/Public/Error.aspx">
                <error statusCode="401" redirect="/Public/Error.aspx?http=401" />       
                <error statusCode="403" redirect="/Public/Error.aspx?http=403" />       
                <error statusCode="404" redirect="/Public/Error.aspx?http=404" />       
                <error statusCode="405" redirect="/Public/Error.aspx?http=405" />       
                <error statusCode="406" redirect="/Public/Error.aspx?http=406" />       
                <error statusCode="408" redirect="/Public/Error.aspx?http=408" />       
                <error statusCode="409" redirect="/Public/Error.aspx?http=409" />       
                <error statusCode="412" redirect="/Public/Error.aspx?http=412" />       
                <error statusCode="413" redirect="/Public/Error.aspx?http=413" />       
                <error statusCode="414" redirect="/Public/Error.aspx?http=414" />       
                <error statusCode="415" redirect="/Public/Error.aspx?http=415" />       
                <error statusCode="500" redirect="/Public/Error.aspx?http=500" />       
                <error statusCode="501" redirect="/Public/Error.aspx?http=501" />       
                <error statusCode="502" redirect="/Public/Error.aspx?http=502" /> 
                <error statusCode="503" redirect="/Public/Error.aspx?http=503" />       
                <error statusCode="504" redirect="/Public/Error.aspx?http=504" />       
                <error statusCode="505" redirect="/Public/Error.aspx?http=505" /> 
            </customErrors>

    keeping tyhe same setup in ApplicationHost.config, and try to force a 401 error, I get redirected to my error page but with error 500??? Really weird, no idea what's going on.

    I checked the Failed Requests log and I correctly get a 401 error there. Where is the 500 coming from??

    Thanks for your time, really appreciate it.

     

     

Page 1 of 1 (7 items)
Page view counter