#StackBounty: #c# #asp.net #asp.net-mvc #asp.net-core #asp.net-core-middleware How to handle dynamic error pages in .net MVC Core?

Bounty: 50

Currently I have

app.UseExceptionHandler("/Home/Error");

I want to make the path relative to the original path.

For example if

Tenant1/PageThatThrowsError then
app.UseExceptionHandler(“Tenant1/Home/Error”);

but if

Tenant2/PageThatThrowsError then
app.UseExceptionHandler(“Tenant2/Home/Error”);

I thought I would be able to do

app.UseExceptionHandler(
    new ExceptionHandlerOptions
    {
        ExceptionHandler = async (ctx) =>
        {
            //logic that extracts tenant
            ctx.Request.Path = new PathString(Invariant($"{tenant}/Home/Error"));
        }
    }
);

but this throws a 500


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.