我在我的Global.asax.cs中有這個Application_Error事件,這將得到我的應用程序中發生的任何未處理的異常。我能夠得到錯誤信息。我試圖得到的還有發生異常的類名稱和方法名稱,以便更容易追蹤異常的原因和位置。請幫忙。獲取類名和方法名異常發生在異常詳細信息
的Global.asax.cs
protected void Application_Error(object sender, EventArgs e)
{
var errMsg = Server.GetLastError().Message;
if (string.IsNullOrWhiteSpace(errMsg)) return;
//Get Class name and method name
//ErrorLog.SaveLog(errMsg, Classname, Methodname);
Context.ClearError();
}
'var errMsg = Server.GetLastError()。StackTrace;' – Arshad 2013-03-20 08:31:47
[this](https://groups.google.com/forum/?fromgroups=#!topic/microsoft.public.dotnet.framework.aspnet/ AxXPD64S1gw)可能是你正在尋找的。 – Tung 2013-03-20 08:33:02