HttpErrors web.config section prevents debugging

I am trying to redirect all errors on the server back to my application so that it can display relevant content and potentially redirect the user to the right place.

IIS 7 Manager added this section to my web.config when I edited error pages through it.

<httpErrors errorMode="Custom"> <remove statusCode="401" subStatusCode="-1" /> <remove statusCode="403" subStatusCode="-1" /> <remove statusCode="405" subStatusCode="-1" /> <remove statusCode="406" subStatusCode="-1" /> <remove statusCode="412" subStatusCode="-1" /> <remove statusCode="502" subStatusCode="-1" /> <remove statusCode="501" subStatusCode="-1" /> <remove statusCode="500" subStatusCode="-1" /> <error statusCode="404" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="500" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="501" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="502" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="412" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="406" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="405" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="403" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> <error statusCode="401" prefixLanguageFilePath="" path="/ErrorPage.aspx" responseMode="ExecuteURL" /> </httpErrors> 

However, now when I try to debug in ASP.Net, I get an error. "Cannot start debugging on a web server. See Help for general configuration errors. Running a web page outside the debugger may provide additional information. Make sure the server is working correctly. Make sure there are no syntax errors in web.config, Debug.Start Without Debugging You can also refer to the "Debugging ASP.NET and ATL Server" section of the online documentation. This happens if the settings are in the web.config file or on applicationHost.config servers.

Running Debug.Start without debugging does not provide any useful information; the site works as usual.

Starting debugging with a section removed from web.config allows you to start it properly. Strange, I can add this section back to web.config after starting the debugger and everything works as expected.

I assume this is because the asp.net debugger is not aware of the IIS configuration section. It really is a pain to delete this section and add it back. Does anyone know how to solve it?

+4
source share
1 answer

Finally found a reasonable job. Install everything in the IIS server configuration (although this will work for a separate site). Set the "Detailed errors for local queries and custom error pages for remote queries" function parameters.

When we need to debug the error page itself, switch it to custom errors after you start debugging.

+2
source

Source: https://habr.com/ru/post/1379139/


All Articles