c# - Handle application error problems -
i using mvc project , hase been logging application errors in global.ascx
.
this code
protected void application_error(object sender, system.eventargs e) { system.web.httpcontext context = httpcontext.current; system.exception exception = context.server.getlasterror(); var stacktraceexcep = new stacktrace(exception, true); // create stack trace var stacktrace = stacktraceexcep.getframes() // frames .select(frame => new { // info filename = frame.getfilename(), linenumber = frame.getfilelinenumber(), columnnumber = frame.getfilecolumnnumber(), method = frame.getmethod(), class = frame.getmethod().declaringtype, }).firstordefault(); string filename = stacktrace.filename; string linenumber = stacktrace.linenumber.tostring(); string columnnumber = stacktrace.columnnumber.tostring(); string methodname = stacktrace.method.name; string classname = stacktrace.class.name; int errornumber = convert.toint32(errorrepository.adderror(exception.message, filename, convert.toint32(linenumber), convert.toint32(columnnumber), methodname, classname));//this line helps stores error in database. response.redirect(string.format("~/error/{0}/?errornumber={1}", "app_error", server.urlencode(errornumber.tostring())));//pass error number cantroller show error number(last inserted id) in view context.server.clearerror(); }
okay let me go problem here
the above code working fine on local computer . code stores (error path , error name ,error line number ,error column number, error method name, error class name .
) in database.
now, when publish project , deploy publish version on server (arvixe
) .
the code in application error method works fine class name method name , exception message
, stores data in database, error line number
, error column number
not stored in database. saw database , it's stores nothing .
what problem ? why error line number
, error column name
not stored when deployed web server(everything works fine on local system) ?
i have doubts
1) project published version , project files(class,controllers,models,etc ( think know that)) converted dll , guess stacktrace
not error line details ? correct ? else tell me .
2)the server not have visual studio . guess not working ? correct else tell me ?
it seems connection string not set properly. handle application error happens when there's no way connect database. open web.config file , add connection string there.
Comments
Post a Comment