在 Razor 项目上使用 WebMatrix 和 Visial Studio 2010
我在 Razor 项目上使用 WebMatrix 和 VS 时遇到问题。我已从 ASP.net 官方网站下载并安装了所有更新。在 VS 中编译项目后,我收到以下错误:
“未提供您请求的页面类型,因为它已被明确禁止。扩展名‘.cshtml’可能不正确。”
现在,当我在 WebMatrix 中打开该项目时,我收到相同的错误。我可以在 WebMatrix 中打开/运行其他项目而不会出现错误,所以显然 VS 更改了我项目中的某些配置?
幸运的是我找到了解决方法,但问题仍然没有解决。
1)为站点创建一个新的空文件夹。
2) 从失败站点复制文件夹内容。
3) 在 WebMatrix 中使用选项“来自文件夹的站点”。
一旦我按照上述步骤启动并运行了站点,我就可以删除原始文件夹,然后将新文件夹(现在正在工作)重命名为原始名称,站点将再次停止工作。我的系统上有一些与原始文件夹名称相关的设置,会阻止提供 cshtml 文件。 那个设置是什么/在哪里?
谢谢,Terrence Koehn
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的 Web 应用程序的根文件夹中没有 .cshtml 文件,则您需要明确进行此设置:
If you don't have a .cshtml file on the root folder of your web app, then you need this setting there explicitly:
您可以尝试在本地 web.config 中添加此设置:
You can try adding this setting in local web.config: