I want to have the exception details shown on the web browser of the user to contain source file and line number information.
I have <customErrors mode="off"/> on the web.config. This allows the user to see the exception details. As follows:
test
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: test
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
However, this information does not include source file and line number. Actually, I do not know / understand what are the numbers that I see at the end of the starck trace lines.
Also, this happens only when I publish the web site on the production server. When I run the project from within Visual Studio 2005 (by choosing View in Browser) I can see the source file and line numbers as follows:
Server Error in '/faxserveradmin' Application.
test
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: test
Source Error:
Line 591: End Sub
Line 592: Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
Line 593: Throw New Exception("test")
Line 594: save()
Line 595: End Sub
Thanks for replying mudassarkhan. However, this does not constitute an answer to my question.
The question is why the same piece of code when run from within Visual Studio 2005 displays at the client browser (through the "View In Browser" functionality) the error message with the source file and source line numbers, while when I publish the web site
on IIS run it from there, the messages do not include this information.
Initially, thank you for taking the time to answer this.
However, you do not answer my question. I have read the articles and I have tried all the examples that they have inside. However, when I run the example on development (from within Visual Studio) I get what I want, i.e. the source file and line number of
the exception, whereas when I deploy on to production server, the line numbers disappear. This is my problem. How to make the production IIS server/application display the line numbers of the point where the exception occurred.
But even if I do what you say, the ".StackTrace()" command displays the source file and line numbers ONLY ON DEVELOPMENT FROM WITHIN VISUAL STUDIO. The question, which you do not answer to me, is how to make it display the source file and line number on
PRODUCTION IIS server OUTSIDE Visual Studio.
pmatsinopoul...
Member
109 Points
48 Posts
Display source file and line number when in production server
Dec 11, 2008 10:49 AM|LINK
Hi,
I want to have the exception details shown on the web browser of the user to contain source file and line number information.
I have <customErrors mode="off"/> on the web.config. This allows the user to see the exception details. As follows:
test
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: test
Source Error:
Stack Trace:
However, this information does not include source file and line number. Actually, I do not know / understand what are the numbers that I see at the end of the starck trace lines.
Also, this happens only when I publish the web site on the production server. When I run the project from within Visual Studio 2005 (by choosing View in Browser) I can see the source file and line numbers as follows:
Server Error in '/faxserveradmin' Application.
test
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Exception: test
Source Error:
Source File: C:\Takis\e-rhetor\svnrepos_mgrcode\trunk\faxserveradmin\IncomingFaxes.aspx.vb Line: 593
Stack Trace:
Can anybody help to achieve the same result on production server where the web site is published?
Thanks in advance
pmatsinopoulos
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Display source file and line number when in production server
Dec 11, 2008 11:28 AM|LINK
use
Server.GetLastError.StackTrace
Server.GetLastError.Message
Server.GetLastError.TargetSite
to get the desired messages
Contact me
pmatsinopoul...
Member
109 Points
48 Posts
Re: Display source file and line number when in production server
Dec 11, 2008 03:12 PM|LINK
Thanks for replying mudassarkhan. However, this does not constitute an answer to my question.
The question is why the same piece of code when run from within Visual Studio 2005 displays at the client browser (through the "View In Browser" functionality) the error message with the source file and source line numbers, while when I publish the web site on IIS run it from there, the messages do not include this information.
pmatsinopoulos
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Display source file and line number when in production server
Dec 11, 2008 03:41 PM|LINK
Hi,
This is a security feature in IIS it does not show ur code on client browsers.
Contact me
pmatsinopoul...
Member
109 Points
48 Posts
Re: Display source file and line number when in production server
Dec 11, 2008 04:05 PM|LINK
Can I change this security feature?
KeFang Chen ...
Star
8329 Points
852 Posts
Re: Display source file and line number when in production server
Dec 15, 2008 09:09 AM|LINK
Hello pmatsinopoulos,
Based on your description, you want to display detail information about the exception.
So you can visit the following websites to get more information on custom error.
http://support.microsoft.com/kb/306355
http://aspnetresources.com/articles/CustomErrorPages.aspx
pmatsinopoul...
Member
109 Points
48 Posts
Re: Display source file and line number when in production server
Dec 15, 2008 04:38 PM|LINK
Hi KeFang Chen,
Initially, thank you for taking the time to answer this.
However, you do not answer my question. I have read the articles and I have tried all the examples that they have inside. However, when I run the example on development (from within Visual Studio) I get what I want, i.e. the source file and line number of the exception, whereas when I deploy on to production server, the line numbers disappear. This is my problem. How to make the production IIS server/application display the line numbers of the point where the exception occurred.
pmatsinopoulos
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Display source file and line number when in production server
Dec 15, 2008 04:47 PM|LINK
One easier way will be to create ur own cutom error page and
display the following on the page
server.GetLastError
.Messageserver.GetLastError.TargetSite.Name
server.GetLastError.StackTrace
Contact me
pmatsinopoul...
Member
109 Points
48 Posts
Re: Display source file and line number when in production server
Dec 15, 2008 05:00 PM|LINK
But even if I do what you say, the ".StackTrace()" command displays the source file and line numbers ONLY ON DEVELOPMENT FROM WITHIN VISUAL STUDIO. The question, which you do not answer to me, is how to make it display the source file and line number on PRODUCTION IIS server OUTSIDE Visual Studio.
Is the question clear?
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Display source file and line number when in production server
Dec 15, 2008 05:09 PM|LINK
No, this will give u line nos on production too. In my company we are using them to log errors
u can get in the following way
strGetCompleteError = Server.GetLastError.StackTrace
intGetPositionOfLine = InStr(strGetCompleteError, ":line")intGetLineNo = InStr(intGetPositionOfLine, strGetCompleteError, vbCrLf, CompareMethod.Binary)
Contact me