Skip to content

Update the ExceptionHandlerMiddleware to support getting the path to redirect to via LinkGenerator #4277

@DamianEdwards

Description

@DamianEdwards

Today, the web app project templates have a block like this:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: DesignThis issue requires design work before implementating.affected-fewThis issue impacts only small number of customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-routingseverity-minorThis label is used by an internal tool
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions