错误页处理
<customErrors mode="RemoteOnly" defaultRedirect="AppErrors.aspx">
<error statusCode="404" redirect="NoSuchPage.aspx"/>
<error statusCode="403" redirect="NoAccessAllowed.aspx"/>
</customErrors>
//本地用户VS远程用户
try
{
sqlConnection1.Open();
sqlDataAdapter1.Fill(dsCustomers1);
}
catch (Exception ex)
{
if(Request.IsLocal)
{ Session["CurrentError"] = ex.Message; }
else
{ Session["CurrentError"] = "Error processing page."; }
Server.Transfer("ApplicationError.aspx");
}
finally
{
this.sqlConnection1.Close();
}
全局 处理异常
protected void Application_Error(Object sender, EventArgs e)
{
Session["CurrentError"] = "Global: " +
Server.GetLastError().Message;
Server.Transfer("lasterr.aspx");
}
转自 百度空间 http://hi.baidu.com/talent_xiaoqiang/blog/item/4a258d450e2bff3e879473af.html

浙公网安备 33010602011771号