Aspnetcore.docs: UseStatusCodePagesWithRedirects doesn't work

Created on 14 May 2018  Â·  3Comments  Â·  Source: dotnet/AspNetCore.Docs

Not sure if I did anything wrong or missed something. Tried to add app.UseStatusCodePagesWithRedirects("/error/{0}"); within Startup.cs under Configure, t gives me a Can't reach this page error. Error Code: INET_E_REDIRECT_FAILED.
Do I need to create a page e.g. 403.cshtml under /Error/ folder?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P2 Source - Docs.ms

Most helpful comment

Thanks @sonichanxiao for mentioning this. Yes, that's correct. Create a view/page for the endpoint. I just so happen to have such a endpoint in a few of my test Razor Pages apps because they use ...

app.UseStatusCodePagesWithReExecute("/Error/{0}");

... so I have a Razor Page (Error.cshtml) set up like this ...

@page "{statusCode?}"
@model ErrorModel

<!DOCTYPE html>
<!-- REST OF THE PAGE FOLLOWS HERE -->

I'll do some work on the doc to make it clear that a page/view must be created to receive a redirect or re-execute.

All 3 comments

Thanks @sonichanxiao for mentioning this. Yes, that's correct. Create a view/page for the endpoint. I just so happen to have such a endpoint in a few of my test Razor Pages apps because they use ...

app.UseStatusCodePagesWithReExecute("/Error/{0}");

... so I have a Razor Page (Error.cshtml) set up like this ...

@page "{statusCode?}"
@model ErrorModel

<!DOCTYPE html>
<!-- REST OF THE PAGE FOLLOWS HERE -->

I'll do some work on the doc to make it clear that a page/view must be created to receive a redirect or re-execute.

Thank you @guardrex , Or an updated sample code in Github would also do the job.

Good idea. I'll make a note on the sample tracking issue for this. #5495

Was this page helpful?
0 / 5 - 0 ratings