问题描述:

I have an asp.net hybrid web forms/mvc application. I'm attempting to use the httpErrors tag in my web.config to redirect to a custom error page when a user attempts to upload a file that exceeds my maxAllowedContentLength.

While the "Redirect" responseMode works fine, I cannot get the "ExecuteUrl" responseMode to work.

This problem occurs both when unit testing in Visual Studio 2013 using IIS Express, and when deployed to a machine running IIS 7.5.

Using "Redirect" with the full path to an mvc controller works fine:

 <httpErrors errorMode="Custom" existingResponse="Replace">

<remove statusCode="404" subStatusCode="13" />

<error statusCode="404" subStatusCode="13" prefixLanguageFilePath=""

path="http://localhost:12345/Error/ErrorFileUploadSizeExceeded" responseMode="Redirect" />

</httpErrors>

However, using "ExecuteUrl" with the relative path does not work (instead I see the default iis 404 page, obviously iis cannot find the relative path):

 <httpErrors errorMode="Custom" existingResponse="Replace">

<remove statusCode="404" subStatusCode="13" />

<error statusCode="404" subStatusCode="13" prefixLanguageFilePath=""

path="/Error/ErrorFileUploadSizeExceeded" responseMode="ExecuteURL" />

</httpErrors>

What do I need to change to get "ExecuteURL" to work?

网友答案:

Please check if your MVC controller is located in the same application pool as your application itself.

For architectural reasons, IIS 7.0 can only execute the URL if it is located in the same Application Pool. Use the redirect feature to execute a Custom Error in a different Application Pool.

相关阅读:
Top