Sunday 15 July 2012

c# - Action method not called when IIS error occurs, just blank page with 403 error -



c# - Action method not called when IIS error occurs, just blank page with 403 error -

i trying capture iis errors not winning @ all. besides errors thrown asp.net, capture errors originate iis. started experiment 404 errors, have chosen other error, chose 404 starting point.

i using latest version of asp.net mvc5 , running website through iis 7.5.

i have next set in web.config:

<system.web> <customerrors mode="off" /> </system.web> <system.webserver> <httperrors errormode="custom" existingresponse="replace"> <remove statuscode="404" substatuscode="-1" /> <error statuscode="404" path="/error/http404" responsemode="executeurl" /> </httperrors> </system.webserver>

i have next in error controller:

public class errorcontroller : controller { public actionresult http404() { response.statuscode = (int)httpstatuscode.notfound; homecoming view(); } }

i throwing error this:

public actionresult index() { homecoming httpnotfound(); }

given settings in web.config action method in error controller not hit. have seen people capture error in application_error method, above code doesn't reach application_error method. can see blank page 403 error status.

why people set above code mine in error controller still go , set error controller , action method called, isn't duplicating work? why 403 error returned blank page?

please don't close question duplicate please help me prepare it. have worked through questions given here on so.

this frustrating.

go filterconfig.cs within app-start folder. add together exception type , error page want specific type of exception.

public static void registerglobalfilters(globalfiltercollection filters) { filters.add(new loggingexceptionfilter()); filters.add(new handleerrorattribute() { exceptiontype = typeof(exception), view = "error" }, 1); filters.add(new handleerrorattribute() { exceptiontype = typeof(httpexception), view = "httpexceptionerror" }, 2); }

create view name httpexceptionerror in shared folder.

c# asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-4

No comments:

Post a Comment