Code to get last error in csharp
1 Answers
Below function LastError() will helps you to get last error occur in code and print that error on to the screen :-
private void LastError()
{
Exception LastError;
String ShowErrMsg;
LastError = Server.GetLastError();
if (LastError!= null)
{
ShowErrMsg= LastError.Message;
}
else
{
ShowErrMsg= “No Errors”;
}
Response.Write(“Last Error = ” + ShowErrMsg);
}