Razor page not working with Rewrite
I have a .cshtml page in a web forms app. When I go to the .cshtml url directly it displays the page just fine.
I also have a httpmodule that does url rewriting. When I rewrite a url to the .cshtml page I get an IIS error:
Server Error in '/' Application.
This type of page is not served.
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:开发者_如何学运维 /pages/1.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Obviously this isn't right because I know the type of page can be served because it works when I go to the url directly.
My rewriter is doing this
HttpApplication.Context.RewritePath("~/pages/1.cshtml", true);
I am running this on IIS7.5 in Windows 7. Does anyone know why this error is coming up? Any suggestions on working around it?
Found it here...
http://learn.iis.net/page.aspx/872/webmatrix-beta-release-readme/
You have to add this to your web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
精彩评论