473,595 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting those built in error pages

I am wanting to get those cool html error pages that ms produces when I hit
an error in asp.net. For instance, when I get a compilation error I get an
html error page that shows me the

Description:
Compiler Error Message:
Source Error:
Source File:

The main thing I want is the Source Error. This give me a few lines of the
code with line numbers.
The other thing is the Compiler Error. This gives me the, "var1 not
declared" or something, error.

Ideally I would like to shoot the html page to my email.

Is this possible.

FYI .... I have this already in the global file.

Dim ex As Exception = Server.GetLastE rror()
request.path
ex.Message
ex.StackTrace
ex.Source
Request.Form.To String()
Request.QuerySt ring.ToString()
ex.TargetSite.T oString()
ex.ToString()

All of which is emailed to me and does not include the line number or the
Compiler Error Message.
Any ideas?

Thanks,
Larry
Nov 18 '05 #1
4 1803
Hi Larry,

Yeah, it's possible but you have to do a little work. You can only get this
info if you have the source code, which in a production app is unlikely.

I have built an WebErrorHandler class that pretty much does what you're
looking for - it generates a detailed error message and logs it and then
also sends an email out with the info.

To get the info you're looking for, you can look at the Server.StackTra ce.
Here's is the key method called Parse from the error handler that takes
common error info and drops it into properties of the WebErrorHandler
object. It includes code to pull the source code if available:
public bool Parse()
{
if (this.LastError == null)
return false;

IsParsed = true;

// *** Use the Inner Exception since that has the actual error info
HttpRequest Request = HttpContext.Cur rent.Request;

this.RawUrl = Request.RawUrl;

if ( LastError is System.IO.FileN otFoundExceptio n)
this.ErrorMessa ge = "File not found: " + LastError.Messa ge;
else
this.ErrorMessa ge = LastError.Messa ge;

this.Time = DateTime.Now;

if (this.CompactFo rmat)
return true;

this .StackTrace = LastError.Stack Trace;
if (this.RetrieveS ourceLines)
{
StringBuilder sb = new StringBuilder(1 024);

// *** Try to retrieve Source Code information
StackTrace st = new StackTrace(Last Error,true);
StackFrame sf = st.GetFrame(0);
if (sf != null)
{
string Filename = sf.GetFileName( );

if (RetrieveSource Lines && Filename != null)
{
int LineNumber = sf.GetFileLineN umber();
if (LineNumber > 0)
{
StreamReader sr = new StreamReader(Fi lename);

// *** Read over unwanted lines
int x = 0;
for (x = 0; x < LineNumber - 4; x++ )
sr.ReadLine();

sb.Append("--- Code ---\r\n");
sb.AppendFormat ("File: {0}\r\n",Filena me);
sb.AppendFormat ("Method: {0}\r\n\r\n",La stError.TargetS ite);
sb.AppendFormat ("Line {0}: {1}\r\n",x + 1,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x + 2,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x + 3,sr.ReadLine() );
sb.AppendFormat ("<b>Line {0}: {1}</b>\r\n", x+
4,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x +5,sr.ReadLine( ));
sb.AppendFormat ("Line {0}: {1}\r\n",x +6,sr.ReadLine( ));
sb.AppendFormat ("Line {0}: {1}\r\n",x +7,sr.ReadLine( ));

sr.Close();
}
}
}

this.SourceCode = sb.ToString();
}

this.FullUrl =
string.Format(" http://{0}{1}",Request .ServerVariable s["SERVER_NAM E"],Request
..RawUrl);
this.IPAddress = Request.UserHos tAddress;

if (Request.UrlRef errer != null)
this.Referer = Request.UrlRefe rrer.ToString() ;

this.Browser = Request.UserAge nt;

if (Request.IsAuth enticated)
this.Login = HttpContext.Cur rent.User.Ident ity.Name;
else
this.Login = "Anonymous" ;

if (Request.TotalB ytes > 0 && Request.TotalBy tes < 2048)
{
this.PostBuffer =
Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(Requ est.TotalBytes) )
;
this.ContentSiz e = Request.TotalBy tes;
}
else if (Request.TotalB ytes > 2048) // strip the result
{
this.PostBuffer =
Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(2048 )) + "...";
this.ContentSiz e = Request.TotalBy tes;
}

return true;

}

The class then wrappers everything up into a single text string that can be
logged and emailed but that's pretty trivial. The final result looks
something like this:

/wwWebstore/admin/ErrorTestPage.a spx

Object reference not set to an instance of an object.
on 12/19/2003 8:47:57 pm

--- Stack Trace ---
at Westwind.WebSto re.ErrorTestPag e.Page_Load(Obj ect sender, EventArgs e)
in
d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs:line 26
at System.Web.UI.C ontrol.OnLoad(E ventArgs e)
at System.Web.UI.C ontrol.LoadRecu rsive()
at System.Web.UI.P age.ProcessRequ estMain()

--- Code ---
File: d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs
Method: Void Page_Load(Syste m.Object, System.EventArg s)

Line 23:
Line 24: // Now explicitly set this value to null
Line 25: Invoice = null;
<b>Line 26: Invoice.GetBlan kRecord();</b>
Line 27: }
Line 28:
Line 29: #region Web Form Designer generated code
--- Request Information ---
Full Url: http://localhost/wwWebstore/admin/ErrorTestPage.aspx
IP: 127.0.0.1
Referer: http://localhost/wwWebstore/admin/
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
1.1.4322; .NET CLR 1.2.30703)
Login: RASNOTEBOOK\rst rahl

Note on the server the source code won't be there so it can't be
retrieved.+++ Rick ---
--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Larry Tate" <dw********@yah oo.com> wrote in message
news:Oy******** ******@TK2MSFTN GP09.phx.gbl...
I am wanting to get those cool html error pages that ms produces when I hit an error in asp.net. For instance, when I get a compilation error I get an
html error page that shows me the

Description:
Compiler Error Message:
Source Error:
Source File:

The main thing I want is the Source Error. This give me a few lines of the
code with line numbers.
The other thing is the Compiler Error. This gives me the, "var1 not
declared" or something, error.

Ideally I would like to shoot the html page to my email.

Is this possible.

FYI .... I have this already in the global file.

Dim ex As Exception = Server.GetLastE rror()
request.path
ex.Message
ex.StackTrace
ex.Source
Request.Form.To String()
Request.QuerySt ring.ToString()
ex.TargetSite.T oString()
ex.ToString()

All of which is emailed to me and does not include the line number or the
Compiler Error Message.
Any ideas?

Thanks,
Larry

Nov 18 '05 #2
That looks cool. What methods are you calling to get all of this info? I can
write a parser to chew through it.

Thanks,
Larry

"Rick Strahl [MVP]" <ri********@hot mail.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...
Hi Larry,

Yeah, it's possible but you have to do a little work. You can only get this info if you have the source code, which in a production app is unlikely.

I have built an WebErrorHandler class that pretty much does what you're
looking for - it generates a detailed error message and logs it and then
also sends an email out with the info.

To get the info you're looking for, you can look at the Server.StackTra ce.
Here's is the key method called Parse from the error handler that takes
common error info and drops it into properties of the WebErrorHandler
object. It includes code to pull the source code if available:
public bool Parse()
{
if (this.LastError == null)
return false;

IsParsed = true;

// *** Use the Inner Exception since that has the actual error info
HttpRequest Request = HttpContext.Cur rent.Request;

this.RawUrl = Request.RawUrl;

if ( LastError is System.IO.FileN otFoundExceptio n)
this.ErrorMessa ge = "File not found: " + LastError.Messa ge;
else
this.ErrorMessa ge = LastError.Messa ge;

this.Time = DateTime.Now;

if (this.CompactFo rmat)
return true;

this .StackTrace = LastError.Stack Trace;
if (this.RetrieveS ourceLines)
{
StringBuilder sb = new StringBuilder(1 024);

// *** Try to retrieve Source Code information
StackTrace st = new StackTrace(Last Error,true);
StackFrame sf = st.GetFrame(0);
if (sf != null)
{
string Filename = sf.GetFileName( );

if (RetrieveSource Lines && Filename != null)
{
int LineNumber = sf.GetFileLineN umber();
if (LineNumber > 0)
{
StreamReader sr = new StreamReader(Fi lename);

// *** Read over unwanted lines
int x = 0;
for (x = 0; x < LineNumber - 4; x++ )
sr.ReadLine();

sb.Append("--- Code ---\r\n");
sb.AppendFormat ("File: {0}\r\n",Filena me);
sb.AppendFormat ("Method: {0}\r\n\r\n",La stError.TargetS ite); sb.AppendFormat ("Line {0}: {1}\r\n",x + 1,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x + 2,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x + 3,sr.ReadLine() );
sb.AppendFormat ("<b>Line {0}: {1}</b>\r\n", x+
4,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x +5,sr.ReadLine( ));
sb.AppendFormat ("Line {0}: {1}\r\n",x +6,sr.ReadLine( ));
sb.AppendFormat ("Line {0}: {1}\r\n",x +7,sr.ReadLine( ));

sr.Close();
}
}
}

this.SourceCode = sb.ToString();
}

this.FullUrl =
string.Format(" http://{0}{1}",Request .ServerVariable s["SERVER_NAM E"],Request .RawUrl);
this.IPAddress = Request.UserHos tAddress;

if (Request.UrlRef errer != null)
this.Referer = Request.UrlRefe rrer.ToString() ;

this.Browser = Request.UserAge nt;

if (Request.IsAuth enticated)
this.Login = HttpContext.Cur rent.User.Ident ity.Name;
else
this.Login = "Anonymous" ;

if (Request.TotalB ytes > 0 && Request.TotalBy tes < 2048)
{
this.PostBuffer =
Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(Requ est.TotalBytes) ) ;
this.ContentSiz e = Request.TotalBy tes;
}
else if (Request.TotalB ytes > 2048) // strip the result
{
this.PostBuffer =
Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(2048 )) + "...";
this.ContentSiz e = Request.TotalBy tes;
}

return true;

}

The class then wrappers everything up into a single text string that can be logged and emailed but that's pretty trivial. The final result looks
something like this:

/wwWebstore/admin/ErrorTestPage.a spx

Object reference not set to an instance of an object.
on 12/19/2003 8:47:57 pm

--- Stack Trace ---
at Westwind.WebSto re.ErrorTestPag e.Page_Load(Obj ect sender, EventArgs e) in
d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs:line 26
at System.Web.UI.C ontrol.OnLoad(E ventArgs e)
at System.Web.UI.C ontrol.LoadRecu rsive()
at System.Web.UI.P age.ProcessRequ estMain()

--- Code ---
File: d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs
Method: Void Page_Load(Syste m.Object, System.EventArg s)

Line 23:
Line 24: // Now explicitly set this value to null
Line 25: Invoice = null;
<b>Line 26: Invoice.GetBlan kRecord();</b>
Line 27: }
Line 28:
Line 29: #region Web Form Designer generated code
--- Request Information ---
Full Url: http://localhost/wwWebstore/admin/ErrorTestPage.aspx
IP: 127.0.0.1
Referer: http://localhost/wwWebstore/admin/
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
1.1.4322; .NET CLR 1.2.30703)
Login: RASNOTEBOOK\rst rahl

Note on the server the source code won't be there so it can't be
retrieved.+++ Rick ---
--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Larry Tate" <dw********@yah oo.com> wrote in message
news:Oy******** ******@TK2MSFTN GP09.phx.gbl...
I am wanting to get those cool html error pages that ms produces when I

hit
an error in asp.net. For instance, when I get a compilation error I get an html error page that shows me the

Description:
Compiler Error Message:
Source Error:
Source File:

The main thing I want is the Source Error. This give me a few lines of the code with line numbers.
The other thing is the Compiler Error. This gives me the, "var1 not
declared" or something, error.

Ideally I would like to shoot the html page to my email.

Is this possible.

FYI .... I have this already in the global file.

Dim ex As Exception = Server.GetLastE rror()
request.path
ex.Message
ex.StackTrace
ex.Source
Request.Form.To String()
Request.QuerySt ring.ToString()
ex.TargetSite.T oString()
ex.ToString()

All of which is emailed to me and does not include the line number or the Compiler Error Message.
Any ideas?

Thanks,
Larry


Nov 18 '05 #3

Ah, sorry forgot that. Server.GetLastE rror() and then use the
InnerException. LastError is basically the Exception that is being parsed
and it's set by the constructor. My class basically parses an exception and
generates the error page from that and then dumps a few of the critical
server vars along with that.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/webblog/
----------------------------------
Making waves on the Web
"Larry Tate" <dw********@yah oo.com> wrote in message
news:OJ******** ******@tk2msftn gp13.phx.gbl...
That looks cool. What methods are you calling to get all of this info? I can write a parser to chew through it.

Thanks,
Larry

"Rick Strahl [MVP]" <ri********@hot mail.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...
Hi Larry,

Yeah, it's possible but you have to do a little work. You can only get this
info if you have the source code, which in a production app is unlikely.

I have built an WebErrorHandler class that pretty much does what you're
looking for - it generates a detailed error message and logs it and then
also sends an email out with the info.

To get the info you're looking for, you can look at the Server.StackTra ce.
Here's is the key method called Parse from the error handler that takes
common error info and drops it into properties of the WebErrorHandler
object. It includes code to pull the source code if available:
public bool Parse()
{
if (this.LastError == null)
return false;

IsParsed = true;

// *** Use the Inner Exception since that has the actual error info
HttpRequest Request = HttpContext.Cur rent.Request;

this.RawUrl = Request.RawUrl;

if ( LastError is System.IO.FileN otFoundExceptio n)
this.ErrorMessa ge = "File not found: " + LastError.Messa ge;
else
this.ErrorMessa ge = LastError.Messa ge;

this.Time = DateTime.Now;

if (this.CompactFo rmat)
return true;

this .StackTrace = LastError.Stack Trace;
if (this.RetrieveS ourceLines)
{
StringBuilder sb = new StringBuilder(1 024);

// *** Try to retrieve Source Code information
StackTrace st = new StackTrace(Last Error,true);
StackFrame sf = st.GetFrame(0);
if (sf != null)
{
string Filename = sf.GetFileName( );

if (RetrieveSource Lines && Filename != null)
{
int LineNumber = sf.GetFileLineN umber();
if (LineNumber > 0)
{
StreamReader sr = new StreamReader(Fi lename);

// *** Read over unwanted lines
int x = 0;
for (x = 0; x < LineNumber - 4; x++ )
sr.ReadLine();

sb.Append("--- Code ---\r\n");
sb.AppendFormat ("File: {0}\r\n",Filena me);
sb.AppendFormat ("Method:

{0}\r\n\r\n",La stError.TargetS ite);
sb.AppendFormat ("Line {0}: {1}\r\n",x + 1,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x + 2,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x + 3,sr.ReadLine() );
sb.AppendFormat ("<b>Line {0}: {1}</b>\r\n", x+
4,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x +5,sr.ReadLine( ));
sb.AppendFormat ("Line {0}: {1}\r\n",x +6,sr.ReadLine( ));
sb.AppendFormat ("Line {0}: {1}\r\n",x +7,sr.ReadLine( ));

sr.Close();
}
}
}

this.SourceCode = sb.ToString();
}

this.FullUrl =

string.Format(" http://{0}{1}",Request .ServerVariable s["SERVER_NAM E"],Request
.RawUrl);
this.IPAddress = Request.UserHos tAddress;

if (Request.UrlRef errer != null)
this.Referer = Request.UrlRefe rrer.ToString() ;

this.Browser = Request.UserAge nt;

if (Request.IsAuth enticated)
this.Login = HttpContext.Cur rent.User.Ident ity.Name;
else
this.Login = "Anonymous" ;

if (Request.TotalB ytes > 0 && Request.TotalBy tes < 2048)
{
this.PostBuffer =

Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(Requ est.TotalBytes) )
;
this.ContentSiz e = Request.TotalBy tes;
}
else if (Request.TotalB ytes > 2048) // strip the result
{
this.PostBuffer =
Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(2048 )) + "...";
this.ContentSiz e = Request.TotalBy tes;
}

return true;

}

The class then wrappers everything up into a single text string that can

be
logged and emailed but that's pretty trivial. The final result looks
something like this:

/wwWebstore/admin/ErrorTestPage.a spx

Object reference not set to an instance of an object.
on 12/19/2003 8:47:57 pm

--- Stack Trace ---
at Westwind.WebSto re.ErrorTestPag e.Page_Load(Obj ect sender, EventArgs

e)
in
d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs:line 26
at System.Web.UI.C ontrol.OnLoad(E ventArgs e)
at System.Web.UI.C ontrol.LoadRecu rsive()
at System.Web.UI.P age.ProcessRequ estMain()

--- Code ---
File: d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs
Method: Void Page_Load(Syste m.Object, System.EventArg s)

Line 23:
Line 24: // Now explicitly set this value to null
Line 25: Invoice = null;
<b>Line 26: Invoice.GetBlan kRecord();</b>
Line 27: }
Line 28:
Line 29: #region Web Form Designer generated code
--- Request Information ---
Full Url: http://localhost/wwWebstore/admin/ErrorTestPage.aspx
IP: 127.0.0.1
Referer: http://localhost/wwWebstore/admin/
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
1.1.4322; .NET CLR 1.2.30703)
Login: RASNOTEBOOK\rst rahl

Note on the server the source code won't be there so it can't be
retrieved.+++ Rick ---
--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Larry Tate" <dw********@yah oo.com> wrote in message
news:Oy******** ******@TK2MSFTN GP09.phx.gbl...
I am wanting to get those cool html error pages that ms produces when
I hit
an error in asp.net. For instance, when I get a compilation error I

get an html error page that shows me the

Description:
Compiler Error Message:
Source Error:
Source File:

The main thing I want is the Source Error. This give me a few lines of the code with line numbers.
The other thing is the Compiler Error. This gives me the, "var1 not
declared" or something, error.

Ideally I would like to shoot the html page to my email.

Is this possible.

FYI .... I have this already in the global file.

Dim ex As Exception = Server.GetLastE rror()
request.path
ex.Message
ex.StackTrace
ex.Source
Request.Form.To String()
Request.QuerySt ring.ToString()
ex.TargetSite.T oString()
ex.ToString()

All of which is emailed to me and does not include the line number or the Compiler Error Message.
Any ideas?

Thanks,
Larry



Nov 18 '05 #4
I hate to keep asking questions on this .... :(

How do I implement this? The main reason I ask is because I am using vb.net.
I should be able to convert it..
Also the function is a boolean with no input.

Do I just call this from like the global.asax file?
sub application_err or(sender As Object, e As EventArgs)
Parse()
end sub
Thanks,
Hate to be such a pain.
Larry
"Rick Strahl [MVP]" <ri********@hot mail.com> wrote in message
news:ex******** ******@TK2MSFTN GP12.phx.gbl...

Ah, sorry forgot that. Server.GetLastE rror() and then use the
InnerException. LastError is basically the Exception that is being parsed
and it's set by the constructor. My class basically parses an exception and generates the error page from that and then dumps a few of the critical
server vars along with that.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/webblog/
----------------------------------
Making waves on the Web
"Larry Tate" <dw********@yah oo.com> wrote in message
news:OJ******** ******@tk2msftn gp13.phx.gbl...
That looks cool. What methods are you calling to get all of this info? I can
write a parser to chew through it.

Thanks,
Larry

"Rick Strahl [MVP]" <ri********@hot mail.com> wrote in message
news:uI******** ******@TK2MSFTN GP11.phx.gbl...
Hi Larry,

Yeah, it's possible but you have to do a little work. You can only get

this
info if you have the source code, which in a production app is unlikely.
I have built an WebErrorHandler class that pretty much does what you're looking for - it generates a detailed error message and logs it and then also sends an email out with the info.

To get the info you're looking for, you can look at the Server.StackTra ce. Here's is the key method called Parse from the error handler that takes common error info and drops it into properties of the WebErrorHandler
object. It includes code to pull the source code if available:
public bool Parse()
{
if (this.LastError == null)
return false;

IsParsed = true;

// *** Use the Inner Exception since that has the actual error info
HttpRequest Request = HttpContext.Cur rent.Request;

this.RawUrl = Request.RawUrl;

if ( LastError is System.IO.FileN otFoundExceptio n)
this.ErrorMessa ge = "File not found: " + LastError.Messa ge;
else
this.ErrorMessa ge = LastError.Messa ge;

this.Time = DateTime.Now;

if (this.CompactFo rmat)
return true;

this .StackTrace = LastError.Stack Trace;
if (this.RetrieveS ourceLines)
{
StringBuilder sb = new StringBuilder(1 024);

// *** Try to retrieve Source Code information
StackTrace st = new StackTrace(Last Error,true);
StackFrame sf = st.GetFrame(0);
if (sf != null)
{
string Filename = sf.GetFileName( );

if (RetrieveSource Lines && Filename != null)
{
int LineNumber = sf.GetFileLineN umber();
if (LineNumber > 0)
{
StreamReader sr = new StreamReader(Fi lename);

// *** Read over unwanted lines
int x = 0;
for (x = 0; x < LineNumber - 4; x++ )
sr.ReadLine();

sb.Append("--- Code ---\r\n");
sb.AppendFormat ("File: {0}\r\n",Filena me);
sb.AppendFormat ("Method:

{0}\r\n\r\n",La stError.TargetS ite);
sb.AppendFormat ("Line {0}: {1}\r\n",x + 1,sr.ReadLine() ); sb.AppendFormat ("Line {0}: {1}\r\n",x + 2,sr.ReadLine() ); sb.AppendFormat ("Line {0}: {1}\r\n",x + 3,sr.ReadLine() ); sb.AppendFormat ("<b>Line {0}: {1}</b>\r\n", x+
4,sr.ReadLine() );
sb.AppendFormat ("Line {0}: {1}\r\n",x +5,sr.ReadLine( )); sb.AppendFormat ("Line {0}: {1}\r\n",x +6,sr.ReadLine( )); sb.AppendFormat ("Line {0}: {1}\r\n",x +7,sr.ReadLine( ));
sr.Close();
}
}
}

this.SourceCode = sb.ToString();
}

this.FullUrl =

string.Format(" http://{0}{1}",Request .ServerVariable s["SERVER_NAM E"],Request
.RawUrl);
this.IPAddress = Request.UserHos tAddress;

if (Request.UrlRef errer != null)
this.Referer = Request.UrlRefe rrer.ToString() ;

this.Browser = Request.UserAge nt;

if (Request.IsAuth enticated)
this.Login = HttpContext.Cur rent.User.Ident ity.Name;
else
this.Login = "Anonymous" ;

if (Request.TotalB ytes > 0 && Request.TotalBy tes < 2048)
{
this.PostBuffer =

Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(Requ est.TotalBytes) )
;
this.ContentSiz e = Request.TotalBy tes;
}
else if (Request.TotalB ytes > 2048) // strip the result
{
this.PostBuffer =
Encoding.GetEnc oding(1252).Get String(Request. BinaryRead(2048 )) + "..."; this.ContentSiz e = Request.TotalBy tes;
}

return true;

}

The class then wrappers everything up into a single text string that can
be
logged and emailed but that's pretty trivial. The final result looks
something like this:

/wwWebstore/admin/ErrorTestPage.a spx

Object reference not set to an instance of an object.
on 12/19/2003 8:47:57 pm

--- Stack Trace ---
at Westwind.WebSto re.ErrorTestPag e.Page_Load(Obj ect sender,
EventArgs
e)
in
d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs:line 26
at System.Web.UI.C ontrol.OnLoad(E ventArgs e)
at System.Web.UI.C ontrol.LoadRecu rsive()
at System.Web.UI.P age.ProcessRequ estMain()

--- Code ---
File: d:\projects\wwW ebStore\Admin\E rrorTestPage.as px.cs
Method: Void Page_Load(Syste m.Object, System.EventArg s)

Line 23:
Line 24: // Now explicitly set this value to null
Line 25: Invoice = null;
<b>Line 26: Invoice.GetBlan kRecord();</b>
Line 27: }
Line 28:
Line 29: #region Web Form Designer generated code
--- Request Information ---
Full Url: http://localhost/wwWebstore/admin/ErrorTestPage.aspx
IP: 127.0.0.1
Referer: http://localhost/wwWebstore/admin/
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET
CLR 1.1.4322; .NET CLR 1.2.30703)
Login: RASNOTEBOOK\rst rahl

Note on the server the source code won't be there so it can't be
retrieved.+++ Rick ---
--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web
"Larry Tate" <dw********@yah oo.com> wrote in message
news:Oy******** ******@TK2MSFTN GP09.phx.gbl...
> I am wanting to get those cool html error pages that ms produces

when I hit
> an error in asp.net. For instance, when I get a compilation error I

get
an
> html error page that shows me the
>
> Description:
> Compiler Error Message:
> Source Error:
> Source File:
>
> The main thing I want is the Source Error. This give me a few lines

of the
> code with line numbers.
> The other thing is the Compiler Error. This gives me the, "var1 not
> declared" or something, error.
>
> Ideally I would like to shoot the html page to my email.
>
> Is this possible.
>
> FYI .... I have this already in the global file.
>
> Dim ex As Exception = Server.GetLastE rror()
> request.path
> ex.Message
> ex.StackTrace
> ex.Source
> Request.Form.To String()
> Request.QuerySt ring.ToString()
> ex.TargetSite.T oString()
> ex.ToString()
>
> All of which is emailed to me and does not include the line number
or the
> Compiler Error Message.
>
>
> Any ideas?
>
> Thanks,
> Larry
>
>



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
17542
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
3
6293
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When I installed Sharepoint Services I got the error and had to reboot and then everything was fine. I get it sometime when running aspx pages. It's very odd. Usually, I can just remove the application and readd it from the properties menu in the IIS...
0
1291
by: Donald Watson | last post by:
I have created data access pages for my database that is sitting in a shared folder on the network so all my users have access to it. Everything works perfectly. I have 2 data access pages built. One is for editing or adding entries to the database. The second is for running a report listing all the current entries. Everything works perfectly but there is one little quirk I haven't figured out yet.
6
1695
by: Binoy | last post by:
Hello, I am getting this error once in a while from my web sites. When I will refresh web browser, it goes off and sites are working fine. Directory structures and file names are as below- C:\WWW - corporate site, C:\WWW\default.aspx is the default page and this site works fine.
8
9998
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
6
3611
by: David Lozzi | last post by:
Hello there, I'm getting the following error System.NullReferenceException: Object reference not set to an instance of an object. at shopping_bag.GetBagTotals()
3
1946
by: Tom | last post by:
I'm building a web application using VS 2005. This application uses Windows authentication to 'authenticate'. However, when I test it (debug) via the VS 2005 built-in test server, it doesn't work. I.E. It won't authenticate. Is there a way to do Windows authentication using the built-in VS 2005 test server? Thanks in advance. Tom --
2
2829
by: Andrew Cooper | last post by:
Greetings, I've got a website that has several pages with DataGrid controls on them. The controls are bound to Object Datasources. On one of the pages I keep getting a "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." error. The data is being filled from a Stored Procedure on an SQL Server. When I run the Stored Procedure on the actual server, it is only taking 24...
4
5698
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working, commercially sold application with only partial build instructions. The previous maintainer of the code (a mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was ...
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3873
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.