Description
Core or SDK?
Platform/SDK
Which part? Which one?
ASP.NET
Description
Documentation can be found here: https://docs.sentry.io/platforms/dotnet/guides/aspnet/
This page does not mention that this setup stops working when custom errors is turned on in the web.config.
example:
<customErrors mode="On" xdt:Transform="Replace">
<error statusCode="404" redirect="~/Error/Error404" />
<error statusCode="401" redirect="~/Error/Unauthorized" />
<error statusCode="403" redirect="~/Error/Forbidden" />
<error statusCode="500" redirect="~/Error/Error500" />
</customErrors>
This is because Application_Error in Galobal.asax.cs does not get called when customErrors is turned on.
Here is a stack overflow post describing the issue here: https://stackoverflow.com/questions/6508415/application-error-not-firing-when-customerrors-on/9572858#9572858
This is a very common way to setup error handling in
Suggested Solution
My solution was to turn off customErrors and implement it at a lower level as described by this article that the stack overflow post links: https://kitsula.com/Article/MVC-Custom-Error-Pages
This way the Application_Error method is stilled called and the error pages are still presented via razor pages without doing a redirect.
My end configuration looked like this:
<httpErrors errorMode="Custom" existingResponse="Replace" xdt:Transform="Insert">
<remove statusCode="401" subStatusCode="-1" />
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="401" path="/Error/Unauthorized" responseMode="ExecuteURL" />
<error statusCode="403" path="/Error/Forbidden" responseMode="ExecuteURL" />
<error statusCode="404" path="/Error/Error404" responseMode="ExecuteURL" />
<error statusCode="500" path="/Error/Error500" responseMode="ExecuteURL" />
</httpErrors>
A small writeup in this documentation section should be written to describe the problem and the possible solutions that the user would want to use. I think the solution I used is good while preventing 302 redirects.
Metadata
Metadata
Assignees
Type
Projects
Status