How can I use existingResponse=”Auto” successfully?

However, the documentation says “SetStatus” flag must be set, but I have no idea how to do such a thing

It’s actually talking about the fTrySkipCustomErrors flag/argument to the IHttpResponse::SetStatus method in the IIS C++ SDK (see note I added to bottom of documentation here). But in ASP.NET the flag is exposed as Response.TrySkipIisCustomErrors. So according to:

http://www.iis.net/configreference/system.webserver/httperrors

Auto = Leaves the response untouched only if the SetStatus flag is set

I would expect to see IIS replace the response with its own html error page content (you can configure what that content is) by default unless you set:

Response.TrySkipIisCustomErrors = true;

Which is what you’re seeing.


Additional related info, in MVC5 it seems to act as if that flag is true even if it’s false for uncaught exceptions which I don’t see in WebForms. As a workaround in Global.asax I’m:

protected void Application_Error()
{
    var error = Server.GetLastError();
    Server.ClearError();
    //code to log error here
    var httpException = error as HttpException;
    Response.StatusCode = httpException != null ? httpException.GetHttpCode() : (int)HttpStatusCode.InternalServerError;
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)