c# - Global.asax - Application_Error - How can I get Page data? -
i have code:
using system.configuration; void application_error(object sender, eventargs e) { exception ex = server.getlasterror().getbaseexception(); string errormessage = ex.message; string stacktrace = ex.stacktrace; string exceptiontype = ex.gettype().fullname; string userid = getloggedinuser(); string weberrorsendemail = configurationmanager.appsettings["weberrorsendemail"]; // save exception in db logstuffindbandsendemailfromdb(); }
this (most of) code. in small percentage of cases, don't enough information though. don't know page exception originated from.
how can kind of information related page exception originated from?
below example of shortest message:
invalid length base-64 char array.
at system.convert.frombase64string(string s) @ system.web.ui.objectstateformatter.deserialize(string inputstring) @ system.web.ui.objectstateformatter.system.web.ui.istateformatter.deserialize(string serializedstate) @ system.web.ui.util.deserializewithassert(istateformatter formatter, string serializedstate) @ system.web.ui.hiddenfieldpagestatepersister.load()
you can current request's url , page :
void application_error(object sender, eventargs e) { // code runs when unhandled error occurs if (httpcontext.current != null) { var url = httpcontext.current.request.url; var page = httpcontext.current.handler system.web.ui.page; } }
Comments
Post a Comment