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
Value – Boolean
- 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.