Code Behind Page Page /Error.aspx.cs (C#)
Used by Page /Error.aspx (C#)
1: using System;  
2: using System.Text;  
3: using System.Data;  
4: using System.Configuration;  
5: using System.Collections;  
6: using System.Web;  
7: using System.Web.Security;  
8: using System.Web.UI;  
9: using System.Web.UI.WebControls;  
10: using System.Web.UI.WebControls.WebParts;  
11: using System.Web.UI.HtmlControls;  
12: using System.Data.SqlClient;  
13: using QuizNetOnline.Logic;  
14: using Microsoft.ApplicationBlocks.Data;  
15:   
16: public partial class ErrorPage : QuiznetOnline.Web.UI.BusinessClasses.BasePage  
17: {  
18:     protected override void Page_Load(object sender, EventArgs e)  
19:     {  
20:         base.Page_Load(sender, e);  
21:   
22:         try  
23:         {  
24:             HttpContext ctx = HttpContext.Current;  
25:   
26:             Exception exception = (Exception)Session["objErr"];  
27:             string OffendingUrl="";  
28:             if (ctx.Request.Url != null && ctx.Request.UrlReferrer != null)  
29:             {  
30:                 OffendingUrl = string.IsNullOrEmpty(ctx.Request.UrlReferrer.ToString()) ? "Referrer unknown" : ctx.Request.UrlReferrer.ToString();  
31:                 lblOffendingUrl.Text = string.Format("Url : {0}",OffendingUrl);  
32:             }  
33:   
34:             if (exception != null)  
35:             {  
36:                 ErrorLog errorlog = new ErrorLog(((UserWeb)Session["userWeb"]).UserName == "guest@quiznetonline.com" ? Request.ServerVariables["REMOTE_HOST"].ToString() : ((UserWeb)Session["userWeb"]).UserName, lblOffendingUrl.Text + System.Environment.NewLine + exception.Message + System.Environment.NewLine + exception.Source + System.Environment.NewLine + exception.StackTrace + System.Environment.NewLine + exception.TargetSite.ToString() + System.Environment.NewLine + QuizNetSystem.ErrorDesc + Environment.NewLine + OffendingUrl, exception.InnerException.ToString(), "Error.aspx Page_Load");  
37:                 errorlog.Save(new SqlWrapper());  
38:   
39:                 if (exception.Message != null)  
40:                     lblErrorMessage.Text = string.Format("Message : {0}",exception.Message);  
41:   
42:                 if (exception.Source != null)  
43:                     lblSource.Text = string.Format("Source : {0}",exception.Source);  
44:   
45:                 if (exception.StackTrace != null)  
46:                     lblStackTrace.Text = string.Format("StackTrace : {0}",exception.StackTrace);  
47:   
48:                 if (exception.HelpLink != null)  
49:                     lblHelpLink.Text = string.Format("HelpLink : {0}", exception.HelpLink);  
50:   
51:                 if (exception.TargetSite != null)  
52:                     lblTargetSite.Text = string.Format("TargetSite : {0}",exception.TargetSite.ToString());  
53:   
54:                 if (exception.InnerException != null)  
55:                     lblInnerException.Text = string.Format("InnerException : {0}", exception.InnerException.ToString());  
56:   
57:                 if (QuizNetSystem.ErrorDesc != null)  
58:                     lblErrorDesc.Text = string.Format("Extra Info : {0}" + QuizNetSystem.ErrorDesc);  
59:   
60:             }  
61:             Server.ClearError();  
62:         }  
63:         catch (Exception ex)  
64:         {  
65:             lblErrorMessage.Text = ex.Message;  
66:         }  
67:     }  
68: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.