exception-handling

Implement global exception handling middleware for ASP.NET Core Razor Pages applications.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill exception-handling-wshaddix
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: exception-handling
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/exception-handling
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill exception-handling-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive strategies for managing errors in ASP.NET Core Razor Pages applications, ensuring a stable and user-friendly experience even when unexpected issues arise.

Core Features & Use Cases

  • Global Exception Handling: Implement application-wide error catching and logging.
  • User-Friendly Error Pages: Display clear, non-technical error messages to users.
  • API Error Responses: Standardize error reporting for API consumers using ProblemDetails.
  • Custom Exception Types: Define domain-specific exceptions for better error categorization.
  • Use Case: When a user encounters an error while submitting a form, this skill ensures a graceful failure, logs the issue for developers, and presents a helpful message to the user instead of a raw server error.

Quick Start

Implement global exception handling middleware in your ASP.NET Core application by adding app.UseGlobalExceptionHandling(); to your Program.cs file.

Frequently Asked Questions about exception-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement global exception handling in ASP.NET Core Razor Pages?▼

Global exception handling in ASP.NET Core Razor Pages is implemented by adding `app.UseGlobalExceptionHandling();` to your `Program.cs` file. This catches application-wide errors, logs issues for developers, and displays user-friendly error pages instead of raw server errors.

What is the best way to standardize API error responses in ASP.NET Core?▼

The best way to standardize API error responses in ASP.NET Core is using the ProblemDetails API. This approach provides a standardized format for reporting API errors to consumers, ensuring consistent error categorization and graceful degradation across your application.

Why does my ASP.NET Core application show raw server errors when a form submission fails?▼

Raw server errors during form submissions occur because ASP.NET Core lacks custom handler-level error management. Defining custom exception types and implementing global middleware ensures graceful failure, logs the issue, and presents a helpful message to the user.

Can I define custom exception types for domain-specific errors in ASP.NET Core?▼

Yes, you can define custom exception types in ASP.NET Core for better domain-specific error categorization. This allows your global exception handling middleware to differentiate between various issues, enabling graceful degradation and appropriate user-friendly error pages.

Does ASP.NET Core middleware support user-friendly error pages for Razor Pages applications?▼

Yes, ASP.NET Core middleware supports user-friendly error pages for Razor Pages applications. By implementing global exception handling, the middleware catches unexpected issues and displays clear, non-technical error messages to users instead of exposing raw server errors.