Posted on 2008-07-18 14:58
星际 阅读(48)
评论(0) 编辑 收藏 网摘
protected void Button2_Click(object sender, EventArgs e)
{
try
{
Convert.ToDateTime("afd");
}
catch(Exception ex)
{
throw ex;
}
}
protected void Page_Error()
{
Exception ex = Server.GetLastError();
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head><title>");
System.Web.HttpContext.Current.Response.Write("错误异常提示");
System.Web.HttpContext.Current.Response.Write(" - 请速与管理员联系</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
System.Web.HttpContext.Current.Response.Write("<style type=\"text/css\"><!-- body { margin: 20px; font-family: Tahoma, Verdana; font-size: 14px; color: #333333; background-color: #FFFFFF; }a {color: #1F4881;text-decoration: none;}--></style></head><body><div style=\"border: #cccccc solid 1px; padding: 20px; width: 500px; margin:auto\" align=\"center\">");
System.Web.HttpContext.Current.Response.Write(ex.Message);
System.Web.HttpContext.Current.Response.Write("</div><br /><br /><br /><div style=\"border: 0px; padding: 0px; width: 500px; margin:auto\"><strong>当前服务器时间:</strong> ");
System.Web.HttpContext.Current.Response.Write(DateTime.Now .ToString ());
System.Web.HttpContext.Current.Response.Write("<br /><strong>错误对象:</strong> ");
System.Web.HttpContext.Current.Response.Write(ex.StackTrace );
System.Web.HttpContext.Current.Response.Write("</div></body></html>");
System.Web.HttpContext.Current.Response.End();
Server.ClearError();
}