Update the ExceptionHandlerMiddleware to support getting the path to redirect to via LinkGenerator
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
Today, the web app project templates have a block like this:
``` c#
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
```
Note the string literal parameter in the call to `app.UseExceptionHandler`. That string (in this case) is the path to a Razor Page (*~/Pages/Error.cshtml*), but as it's a string literal, if the page's route changes (e.g. because its name changes or another route for it is configured) this string path will now be wrong.
It would be great if the middleware allowed the user to specify the path using a `LinkGenerator` (expression?) such that strongly-typed paths to MVC endpoints in 2.2 (and in 3.0 any endpoint) could be done.
@rynowak @JamesNK
Contributor guide
Assessment
This issue has not been assessed yet.