exception-handling

Implement comprehensive exception handling in ASP.NET Core Razor Pages applications.

Updated May 28, 2026
One-click install
npx skills add https://github.com/ojrojas/AgentsInstructions --skill exception-handling-ojrojas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: exception-handling
Source: https://github.com/ojrojas/AgentsInstructions/tree/main/.claude/skills/exception-handling
Command: npx skills add https://github.com/ojrojas/AgentsInstructions --skill exception-handling-ojrojas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to implementing robust exception handling in ASP.NET Core Razor Pages applications, addressing issues such as unhandled exceptions, information leakage, and poor user experience.

Core Features & Use Cases

  • Global Exception Handler Configuration: Set up global exception handling middleware for development and production environments.
  • Custom Error Pages: Create custom error pages to display user-friendly messages.
  • Exception Middleware: Implement custom middleware for more granular exception handling.
  • Custom Exceptions: Define domain-specific exceptions for different error scenarios.
  • ProblemDetails API: Utilize the ProblemDetails API for consistent error responses.
  • Handler-Level Exception Handling: Implement exception handling at the handler level for better control.
  • Background Service Exception Handling: Ensure background services handle exceptions gracefully.
  • MediatR Exception Handling Behavior: Use MediatR to handle exceptions in a request-response pipeline.
  • Anti-Patterns: Learn from common anti-patterns to avoid common pitfalls in exception handling.

Quick Start

Set up global exception handling in your ASP.NET Core Razor Pages application by configuring the exception handling middleware in Program.cs.

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?

You can implement global exception handling by configuring exception handling middleware in Program.cs to catch unhandled exceptions across development and production environments. This Skill provides a structured guide to set up global handlers and custom error pages.

What is the best way to return consistent error responses in ASP.NET Core?

The best way to return consistent error responses in ASP.NET Core is utilizing the ProblemDetails API. This Skill guides you through implementing ProblemDetails to standardize error payloads and prevent sensitive information leakage during exception scenarios.

Does this exception handling guide support ASP.NET Core background services?

Yes, this exception handling guide supports ASP.NET Core background services. It covers specific patterns to ensure background services handle exceptions gracefully, preventing crashes and maintaining application stability during asynchronous operations.

Can I use MediatR exception handling behavior with ASP.NET Core Razor Pages?

Yes, you can use MediatR exception handling behavior with ASP.NET Core Razor Pages. This Skill includes implementing MediatR pipeline behaviors to catch and process exceptions within the request-response pipeline effectively.

What are common exception handling anti-patterns in ASP.NET Core?

Common exception handling anti-patterns in ASP.NET Core include swallowing exceptions, leaking sensitive stack traces to users, and lacking global middleware. This Skill highlights these pitfalls to help you avoid poor user experiences and security risks.

Do I need .NET 8 to use custom exceptions and middleware for error handling?

You need .NET 8 or later with nullable reference types enabled to fully utilize the custom exceptions and exception middleware patterns provided. This Skill targets the .NET 8+ framework to implement robust, type-safe error handling.