asp.net mvc 3 - Getting URL for FileDoesNot Exist with MVC3 and .Net error handling? -
using following error handling in application_error():
protected void application_error() { exception exception = server.getlasterror(); response.clear(); httpexception httpexception = exception httpexception; if (httpexception != null) { string action; switch (httpexception.gethttpcode()) { case 404: // page not found action = "httperror404"; break; case 500: // server error action = "httperror500"; break; default: action = "general"; break; } // clear error on server server.clearerror(); response.redirect(string.format("~/error/{0}/?message={1}", action, exception.message)); } }
prior adding this, pages rendered fine. i've added this, i'm getting 21 file not found exceptions. thought routing values wrong (but don't execute until try route), commented them out, same thing.
i stepped through initial page load up, , since entire page renders @ once, once, wasn't able trace down these coming from, , stacktrace doesn't give me i'm looking for:
at system.web.staticfilehandler.getfileinfo(string virtualpathwithpathinfo, string physicalpath, httpresponse response)
@ system.web.staticfilehandler.processrequestinternal(httpcontext context, string overridevirtualpath) @ system.web.defaulthttphandler.beginprocessrequest(httpcontext context, asynccallback callback, object state) @ system.web.httpapplication.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() @ system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously)
i thought maybe occurring css , scripts defined, commenting these out did nothing fix issue.
how can track down?
i bet 5 bucks it's favicon.ico
file browsers request , didn't provide. inside error handler @ request.url
property in debug mode see requested url , know file missing. if intend redirect @ end of error handler do, calling server.clearerror();
doesn't make sense.
Comments
Post a Comment