> For the complete documentation index, see [llms.txt](https://wiki.owain.codes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.owain.codes/coding/tips-how-to/detailed-error-messages-on-azure.md).

# Detailed Error messages on Azure

To enable detailed errors, you can use the *ASPNETCORE\_DETAILEDERRORS* environment variable or configure the application to always show detailed error pages.

Example: Using ASPNETCORE\_DETAILEDERRORS

Add the following configuration to your *web.config* file when hosting on IIS:

```
<configuration>
 <system.webServer>
   <aspNetCore processPath="dotnet" arguments=".\YourApp.dll">
     <environmentVariables>
       <environmentVariable name="ASPNETCORE_DETAILEDERRORS" value="true" />
     </environmentVariables>
   </aspNetCore>
 </system.webServer>
</configuration>
```

Example: Developer Exception Page in Code

In your *Startup.cs* or *Program.cs*, enable the **Developer Exception Page** for the Development environment:

```
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
   app.UseDeveloperExceptionPage();
}
else
{
   app.UseExceptionHandler("/Error");
   app.UseHsts();
}
app.Run();
```

This ensures that detailed error pages are shown only during development.

Important Considerations

1. **Environment-Specific Configuration**: Always restrict detailed error messages to the Development environment. Exposing them in Production can lead to security risks.
2. **Custom Error Pages**: For Production, use *UseExceptionHandler* to redirect users to a custom error page.
3. **Testing**: Test your error-handling setup thoroughly to ensure no sensitive information is leaked.

By following these practices, you can debug effectively during development while maintaining security in production.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.owain.codes/coding/tips-how-to/detailed-error-messages-on-azure.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
