Reputation: 155692
In a ASP.Net 4 and MVC2 application we have an odd configuration error.
The web.config looks something like this:
<configuration>
<location path="blockedpath">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
<system.web>
<customErrors mode="On" defaultRedirect="~/Error.aspx" />
</system.web>
</configuration>
Visiting the blocked location is correctly denied, but gives a verbose error message from IIS that we don't want.
Why doesn't it serve up the configured custom error?
Can we control what page it does serve up when page access is denied by config?
Upvotes: 2
Views: 693
Reputation: 47144
According to this blog post, IIS7 is trying to be helpful and likes to steal your custom errors pages and replace them with its own.
Open the Error Pages feature in IIS and click Edit Feature Settings on the right hand menu. Set the Detailed errors option to have IIS pass through whatever errors you serve up from ASP.NET.
Upvotes: 1
Reputation: 119806
If this is IIS7 then it looks like IIS is hijacking the response. Try this:
<configuration>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
Upvotes: 0