我只想用getlasterror對象顯示錯誤細節。如何使用asp.net 4.0獲取getlasterror()對象的錯誤細節
這裏是我的web配置代碼重定向自定義錯誤頁:
<customErrors mode="On" defaultRedirect="Error.aspx"/>
這裏是我Error.aspx頁面代碼來捕獲錯誤:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class Error : newManageClass
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadError(Server.GetLastError());
}
}
protected void LoadError(Exception objError)
{
if (objError != null)
{
StringBuilder lasterror = new StringBuilder();
if (objError.Source != null)
{
//lasterror.AppendLine("Source:");
//lasterror.AppendLine(objError.Source);
//lasterror.AppendLine();
lbl_from_page.Text = objError.Source.ToString();
}
if (objError.Message != null)
{
//lasterror.AppendLine("Message:");
//lasterror.AppendLine(objError.Message);
//lasterror.AppendLine();
lbl_errormessage.Text = objError.Message.ToString();
}
//if (objError.InnerException != null)
//{
// lasterror.AppendLine("StackTrace:");
// lasterror.AppendLine(objError.StackTrace);
// lasterror.AppendLine();
// lbl_error_desc.Text = objError.InnerException.ToString();
//}
ViewState.Add("LastError", lasterror.ToString());
}
}
}
我怎麼過不了細節從哪個頁面提供完整的網址和錯誤消息。
請幫我...
如何獲得正在拋出錯誤的頁面的完整url。在object.Source – Shal