Errors are not redirected to the Http handler if redirectMode = "ResponseRewrite"

I see similar questions, but it looks like they were related to an unrelated issue.

in 3.5, I have my own error handler that logs errors and redirects users. My web.config is configured as such:

    <httpHandlers>
                 <add path="error.ashx" type="MySite.Tools.WebErrorLogger, MySite.Tools" verb="*"/>
    </httpHandlers>
    <customErrors mode="On" defaultRedirect="error.ashx"
                  redirectMode="ResponseRewrite">
    </customErrors>

      

If the redirectMode is set to a value "ResponseRedirect"

, everything works fine (but Server.GetLastError () is null, but this seems to be intended)

However, when used, ResponseRewrite

my handler is not called and I see the default ASP.Net error pages. Any idea on how I can do this?

(Unfortunately, I cannot use the aspx page or do error handling in global.asax due to other restrictions)

+2


a source to share


3 answers


Ok, I have asked a pretty similar question in the past.



The solution turned the error page into a static HTML page.
Of course there must be some error on the dynamic page, but I couldn't find it.

0


a source


I came across the same problem and I found that apparently the reason is in the .ashx file, if you are using normal .aspx it will work, it was for me; im still trying to figure out how to "enable" the .ashx file extension using REsponseRewrite as that would be more logical than using an aspx page in my case. Here's an open thread about this thread:



http://social.msdn.microsoft.com/Forums/it-IT/aspnetit/thread/7b8f5e36-44a8-40ea-bd73-2e99a1fd42dd

0


a source


There is no way to do this with a handler ashx

in the current .NET (since 4.5).

ResponseRewrite

uses HttpServerUtility.Execute

which is hardcoded to only allow aspx pages or static files (or legacy ASP pages).

0


a source







All Articles