首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Global.asax - Application_Error -如何获取页面数据?

Global.asax - Application_Error -如何获取页面数据?
EN

Stack Overflow用户
提问于 2013-04-05 21:55:28
回答 1查看 20.2K关注 0票数 19

我有这样的代码:

代码语言:javascript
复制
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 the exception in DB
    LogStuffInDbAndSendEmailFromDb();
}

这是(大部分)我的代码。在一小部分情况下,我没有得到足够的信息。我不知道异常来自哪个页面。

我如何才能获得与产生异常的页面相关的任何类型的信息?

以下是最短消息的示例:

Base-64字符数组的长度无效。

at System.Web.UI.ObjectStateFormatter.Deserialize(String System.Convert.FromBase64String) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter inputString) at System.Web.UI.ObjectStateFormatter.Deserialize(String serializedState) at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String inputString) at System.Web.UI.ObjectStateFormatter.Deserialize(String格式化程序,字符串serializedState) at System.Web.UI.HiddenFieldPageStatePersister.Load()

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15835802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档