I am looking at the ASP.NET MVC4 application which is calling
Server.TransferRequest("Error.cshtml") while executing one of the requests where
Foo.cshtml is a view page residing in the root folder of the application. Everything is working fine on our old server, but once I deployed this app to our new 2012r2 server with IIS8 I am getting following error page:
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /Error.cshtml
Why is that? How to make
TransferRequest work? What setup to perform on new server? To reproduce you can quite simply create a new ASP.NET MVC5 project, add
Error.cshtml razor page to its folder, then in the
Index action of
HttpContext.Server.TransferRequest("Error.cshtml") and preview, you should get the same error as above.
Once I put a breakpoint in
Application_Error method in
Global.Asax.cs and preview the app, I get an exception:
Message: Path '/WebApplication1/Error.cshtml' is forbidden.
at System.Web.HttpForbiddenHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Also, if I deploy mew ASP.NET MVC5 test app calling the
TransferRequest to our old server (server 2008), it is still not working and throws an exception... So it seems like both old server and the original ASP.NET MVC4 app are somehow magically configured to make this thing work...