Home Why can't we use *.cshtml files as custom error pages now that (v4.7) we have "Razor Web Pages"?

# Why can't we use *.cshtml files as custom error pages now that (v4.7) we have "Razor Web Pages"?

Rabbi
1#
Rabbi Published in 2017-12-03 13:02:38Z
 B"H Trying to revamp my global error handling, and running into the mess that is ASP.net error handlers. I would really like to consolidate my solution as much as possible. So if possible I'd like to use the same pages to display from httpErrors and customErrors. I'd also like to use the appropriate Layout pages if possible. But it seems that if I want to use some kind of dynamic page as a custom error page that it needs to be *.aspx. Why is that? Especially now that we have Razor Web Pages? PS. This is for an MVC (.net v4.7 ie not asp core) Site
Dan Soper
2#
Dan Soper Reply to 2017-12-05 15:17:04Z
 If you are using the .cshtml file as a Razor Web Page, then can't you give the URL of the file, excluding the .cshtml? As per the table here: https://docs.microsoft.com/en-us/aspnet/core/mvc/razor-pages/?tabs=visual-studio A standalone .cshtml file is will normally depend on a Code behind file (if using Razor Web Pages) or a MVC Controller Action to provide it with its data. I guess this is why you are not allowed to redirect directly to one.
 You need to login account before you can post.
Processed in 0.30837 second(s) , Gzip On .