HttpResponse.TrySkipIisCustomErrors Property

HttpResponse.TrySkipIis CustomErrors Property

Gets or sets a value that specifies whether IIS7.0 custom errors are disabled.

public: property bool TrySkipIisCustomErrors { bool get(); void set(bool value);  };

Property ValueBoolean - true to disable IIS custom errors; otherwise, false.
The TrySkipIisCustomErrors property is used only when your application is hosted in IIS 7.0 and later. When running in Classic mode, the TrySkipIisCustomErrors property default value is true. When running in Integrated mode, the TrySkipIisCustomErrors property default value is false.

Example,
public void Application_Error(Object sender, EventArgs e)
{
    Exception exception = Server.GetLastError();
    Server.ClearError();

    var routeData = new RouteData();
    routeData.Values.Add("controller", "Errors");
    routeData.Values.Add("action", "Error");
    routeData.Values.Add("exception", exception);

    if (exception.GetType() == typeof(HttpException))
    {
        routeData.Values.Add("statusCode", ((HttpException)exception).GetHttpCode());
    }
    else
    {
        routeData.Values.Add("statusCode", 500);
    }

    Response.TrySkipIisCustomErrors = true; //true to disable IIS custom errors; otherwise, false

    IController controller = new ErrorsController();
    controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
    Response.End();
}

Note the use of Response.TrySkipIisCustomErrors, which is used in multiple places right before a specific response is returned to IIS.
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^