Showing posts from February, 2020

Using TempData and Creating Custom Exception Filter in ASP.NET Core 3.1

The exception handling in Web application is the most important part. Exception Handling must be implemented so that if the the HTTP request processing is failed on the server and exception occurred then the error page with required error must be shown to the user.    Filters in ASP.NET Core In ASP.NET Core, Filters allows code to before or after specific stages in the request pipeline are executed e.g. OnActionExecuting and OnActionExecuted().  We have standard filters like Authorization and ResponseCaching. We can add custom filters in the request pipeline for additional operations e.g. Exception Handling, Custom Authorization, etc. The following figure will explain  filter execution in ASP.NET Core 3,1 application  Figure 1: The Filter Execution As shown in the above figure, filters are executed in MVC application pipeline. This means that when MVC controllers are requested the filters will be loaded in the pipeline and they are executed as per the configuration. For ex