0

Could custom error page be applied to to specific folder in IIS?

For example, my folder name is http://my.com/foobar, in IIS, I right clicked on the folder name >>> .Net Error Pages Icon >>> Add... >>> 404 >>>>> Absolute URL >>http://my.com/error.html

This did not work. I checked in web.config file. There is nothing modified by IIS either. Am I doing something wrong?

~~~~~~~~~~~~~~~~ I add to this:

I tried the configuration:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors>
            <error redirect="error.html" statusCode="403" />
        </customErrors>
    </system.web>
</configuration>

This is no Go.

So I tried

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <httpErrors errorMode="Custom" >
        <remove statusCode="403" subStatusCode="-1" />
        <error statusCode="403" path="http://my.com/err.html" responseMode="Redirect" />
        </httpErrors>
    </system.web>
</configuration>

This worked, but this was added to the web.config under root, is there any way to add for a directory web.config?

4
  • Create a Custom HTTP Error Response (IIS 7) Commented Dec 15, 2014 at 15:22
  • @huMptyduMpty Hi, please see my update, could you advise? thanks. Commented Dec 15, 2014 at 16:38
  • I haven't tried this myself, but the article mention that "If Execute a URL on this site is selected, the path must be a URL relative to the root of the current site" Commented Dec 15, 2014 at 16:41
  • i don't think it's a path issue, since the page is not being redirected at all. Yet I found another way and it worked. Thanks anyways though. Commented Dec 15, 2014 at 17:17

1 Answer 1

1

I added this to directory web.config, and it worked.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
        <httpErrors errorMode="Custom" >
                                <remove statusCode="403" subStatusCode="-1" />
                                <error statusCode="403" path="`___REDIRECT URL HERE________`" responseMode="Redirect" />
                                </httpErrors>
   </system.webServer>
</configuration>

My question remaining: how is this different from the default way of doing it from IIS directly? Like this -

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors>
            <error redirect="error.html" statusCode="403" />
        </customErrors>
    </system.web>
</configuration>

I heard this is working in IIS6 but not 7/7.5?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.