Kumar Ravishankar

Kumar Ravishankar

  • NA
  • 437
  • 7.9k

How to get exact exception issue

Apr 24 2018 2:48 AM
I am using below code in My Error page , its working fine but want to get the exact issue of exception ,to resolve it , How can I do this for the same..
 
What I have tried:

if (ex != null)
{
StringBuilder lasterror = new StringBuilder();
if (ex.Message != null)
{
lasterror.AppendLine("Message:");
lasterror.AppendLine(ex.Message);
lasterror.AppendLine();
}
if (ex.InnerException != null)
{
lasterror.AppendLine("
InnerException:");
lasterror.AppendLine(ex.InnerException.ToString());
lasterror.AppendLine();
}

if (ex.Source != null)
{
lasterror.AppendLine("
Source:");
lasterror.AppendLine(ex.Source);
lasterror.AppendLine();
}

if (ex.StackTrace != null)
{
lasterror.AppendLine("
StackTrace:");
lasterror.AppendLine(ex.StackTrace);
lasterror.AppendLine();
}

lblException.Text = lasterror.ToString();
} 

Answers (1)