Using WebMatrix and Visial Studio 2010 on a Razor project
I am having problems using both WebMatrix and VS on a Razor project. I have downloaded and installed all updates from the official ASP.net web site. After getting the project to compile in VS I get the following error:开发者_开发百科
"The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect."
Now when I open the project in WebMatrix I receive the same error. I can open/run other projects in WebMatrix without errors so apparently VS changed some configuration in my project?
Fortunately I have found a work around but the problem is still not solved.
1) Create a new empty folder for site.
2) Copy contents of folder from failing site.
3) In WebMatrix use option "Site From Folder".
Once I have the site up and running with the above steps I can delete the original folder, then rename the new folder (which is now working) to the orig name and the site will stop working again. There is some setting on my system tied to the original folder name that is stopping cshtml files from being served. What/Where is that setting?
Thanks, Terrence Koehn
If you don't have a .cshtml file on the root folder of your web app, then you need this setting there explicitly:
<appSettings>
<add key="webpages:Enabled" value="true" />
</appSettings>
You can try adding this setting in local web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
精彩评论