Login Register
Code2night
  • Home
  • Blog Archive
  • Learn
    • Tutorials
    • Videos
  • Interview Q&A
  • Languages
    • Angular Angular js ASP.NET Asp.net Core ASP.NET Core, C# C C# DotNet
      HTML/CSS Java JavaScript Node.js Python Python 3.11, Pandas, SQL Python 3.11, SQL Python 3.11, SQLAlchemy
      Python 3.11, SQLAlchemy, SQL Python 3.11, SQLite React Security SQL Server TypeScript
  • Post Blog
  • Tools
    • Beautifiers
      JSON Beautifier HTML Beautifier XML Beautifier CSS Beautifier JS Beautifier SQL Formatter
      Dev Utilities
      JWT Decoder Regex Tester Diff Checker Cron Explainer String Escape Hash Generator Password Generator
      Converters
      Base64 Encode/Decode URL Encoder/Decoder JSON to CSV CSV to JSON JSON to TypeScript Markdown to HTML Number Base Converter Timestamp Converter Case Converter
      Generators
      UUID / GUID Generator Lorem Ipsum QR Code Generator Meta Tag Generator
      Image Tools
      Image Converter Image Resizer Image Compressor Image to Base64 PNG to ICO Background Remover Color Picker
      Text & Content
      Word Counter PDF Editor
      SEO & Web
      SEO Analyzer URL Checker World Clock
  1. Home
  2. Blog
  3. ASP.NET MVC
  4. Exception Handling and Creating Exception Logs in Asp.net MVC

Exception Handling and Creating Exception Logs in Asp.net MVC

Date- Aug 05,2020

Updated Jan 2026

20461

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.

Exception Handling and Creating Exception Logs in Aspnet MVC

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

Exception Handling and Creating Exception Logs in Aspnet MVC 2
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.

Exception Handling and Creating Exception Logs in Aspnet MVC 3

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.

Exception Handling and Creating Exception Logs in Aspnet MVC 4

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

Related Articles

How to Import CSV in ASP.NET MVC
Feb 02, 2024
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
Next in ASP.NET MVC
Stopping Browser Reload On saving file in Visual Studio Asp.Net

Comments

On this page

🎯

Interview Prep

Ace your ASP.NET MVC interview with curated Q&As for all levels.

View ASP.NET MVC Interview Q&As

More in ASP.NET MVC

  • Implement Stripe Payment Gateway In ASP.NET 58652 views
  • Jquery Full Calender Integrated With ASP.NET 39559 views
  • Microsoft Outlook Add Appointment and Get Appointment using … 27507 views
  • How to implement JWT Token Authentication and Validate JWT T… 25188 views
  • Payumoney Integration With Asp.Net MVC 23150 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 | 1770
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
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • SQL Formatter
  • Diff Checker
  • Regex Tester
  • Markdown to HTML
  • Word Counter
More Tools
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Base64 Encoder
  • JWT Decoder
  • UUID Generator
  • Image Converter
  • PNG to ICO
  • SEO Analyzer
By Language
  • Angular
  • Angular js
  • ASP.NET
  • Asp.net Core
  • ASP.NET Core, C#
  • C
  • C#
  • DotNet
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • Python 3.11, Pandas, SQL
  • Python 3.11, SQL
  • Python 3.11, SQLAlchemy
  • Python 3.11, SQLAlchemy, SQL
  • Python 3.11, SQLite
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page
We use cookies to improve your experience and analyze site traffic. By clicking Accept, you consent to our use of cookies. Privacy Policy
Accessibility
Text size
High contrast
Grayscale
Dyslexia font
Highlight links
Pause animations
Large cursor