Login Register
Code2night
  • Home
  • Guest Posts
  • Blog Archive
  • Tutorial
  • Languages
    • Angular
    • C
    • c#
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • Security
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
    • SEO Analyzer
  1. Home
  2. Blog
  3. Exception Handling and Creating Exception Logs in Asp.net MVC

Exception Handling and Creating Exception Logs in Asp.net MVC

Date- Aug 05,2020

20401

Aspnet

Exception Handling and Creating Exception Logs in Asp.net Mvc  :-

As per a Developer we have to face issue of handling Exception Effectively.In this Article we will see how to handle exceptions effectively in Asp.Net MVC.So Let's See how it works:-

Base Controller:- 

So basically in a MVC Project  we often use many controllers for making our web project functional.So one way is to handle exception separately on all of them or we can simple use a Base Controller. A Base controller can be told as a parent controller from which all other controller will inherit.So in that way Exception handling performed on Base Controller will get applied on all controllers which inherits from  this controller.


So you can see a Base Controller which has OnException Method to handle all the exceptions

This Error Log Method is used to add Logs to your Log File so that you can check your exceptions for debugging in a better way.

Inherit Controller from Base Controller:-
So after we have successfully set up OnException Action Method and Error Log File Now we can inhrit controllers from this Base Controller.


So this is how you can use your base controller with all controllers simply by inheriting.Now whenever any exception will occur on you Blog Controller or your controller it will Log its Details in Log Files.


S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

How to refund payment using Paypal in Asp.Net MVC
Jan 30, 2024
How to Use Stored Procedures with Parameters in Dapper
Jan 23, 2024
Repopulating and Reselecting same Row in DevExpress Grid
Jan 19, 2024
Get random number in asp.net C#
Dec 23, 2023

Comments

Contents

More in ASP.NET MVC

  • Implement Stripe Payment Gateway In ASP.NET 58608 views
  • Jquery Full Calender Integrated With ASP.NET 39524 views
  • Microsoft Outlook Add Appointment and Get Appointment using … 27448 views
  • How to implement JWT Token Authentication and Validate JWT T… 25156 views
  • Payumoney Integration With Asp.Net MVC 23100 views
View all ASP.NET MVC posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
  • SEO Analyzer
By Language
  • Angular
  • C
  • c#
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page