Handling exceptions multiple ways in asp.net application

Varuni Rao 1 Reputation point
2021-05-17T13:13:19.327+00:00

In my application I need to display error message in two different ways based on severity.

  1. Contacting Administrator if severity is high.
  2. User handling the error by themselves without contacting administrator.

I achieved first one like as follows:
Try
{
//code
}
catch(Exception ex)
{
Exception("Contact Admin");
}

How to achieve 2nd one can anyone five solutions for this.

Thanks In Advance.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,277 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,286 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Duane Arnold 3,216 Reputation points
    2021-05-17T15:51:49.563+00:00

    @Varuni Rao

    A user with a browser cannot handle an exceptions his or herself.

    There should be using global exception handling in the solution with the exception.message, stack trace and inner.exception if inner.excpetion is not null being logged to a log file with a redirect to a user friendly error page about "contact site administration". You can review what has been logged to the log file. Log4Net is a good logging framework you can use.

    You don't need any try/catch in any code, becuase the global exception handler code catches all exceptions even for code that has been referenced by the project that is doing the referencing to the referenced project or DLL.

    https://stackify.com/csharp-catch-all-exceptions/

    Q&A has tags for dotnet.ASP.NET you can post to for help.

    HTH

    0 comments No comments