简体   繁体   中英

I am not being able to see a detailed output of a server error?

In asp.net, i can't see the detailed message of the server when an error is present. I mean, when you open a browser and navigate to say http://[errorpage].com and the page shows something like "internal server error - the server is busy" - surely you know that the server is busy...but with my application i get only error 503 - but i cant go as far as mozilla browser goes and cannot see the entire error message. I tried to catch and display the exception - but...no. also i tried to parse the source with regular exp. - but i guess net stops whenever error is present and cannot proceed to parsing - also...without trycatching: same thing.

As a rule, don't enable this on live websites. In your web.config, add/edit the following:

<customErrors mode="Off" />

This will start showing detailed info about the error. But again, DO NOT do this on a live server, or at least not permanently, as it is a security hazard.

The best way to do that is to implement error handling into your code, then save errors somewhere (database, file ...) Then you can look into your file and get a full error

eg

try {
   //your code here
}
catch(Exception ex)
{
   //write to file ex.ToString() to see whole stack trace, or ex.Message to see just message like "index out of bounds"
}

and also if you want to get errors in browser then turn it on in your config file

look at this link for details http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx

Your question is a little manic, but you've got to consider what error handling is going on up the stack if this is happening:

try{
   //Something
}
catch(Exception){
   //Handle it some how
   throw new Exception("Broken");
}

then this will loose all of the call stack before the new exception is thrown. If this is happening it can be fixed like this:

try{
   //Something
}
catch(Exception){
   //Handle it some how
   throw;
}

this continues to throw the original exception with stack trace.

如果打开ASP.NET Health Monitoring ,则ASP.NET会将错误的详细信息记录到Windows事件日志或您指定的任何其他目标位置。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM