c# - MVC Application_start localhost redirected you too many times -
i error:
localhost redirected many times.
when redirect error page application_start
method.
my code looks this:
protected void application_start() { arearegistration.registerallareas(); routeconfig.registerroutes(routetable.routes); } protected void application_error(object sender, eventargs e) { var exception = server.getlasterror(); if (exception != null) { session["w"] = exception; response.clear(); server.clearerror(); response.redirect("~/admin/error"); } } }
it not idea use session in case. if error triggered ihttphandler
not marked irequiressessionstate
, accessing session fail. so, have redirect loop.
remove using of session , try use:
response.redirect(string.format("~/admin/error?w={0}", exception.message));
Comments
Post a Comment