C#和Razor-由于已明确禁止您请求的页面类型,因此无法提供.扩展名".cshtml"可能不正确 [英] C# and Razor - The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect
问题描述
我浏览了其他帖子,但似乎都没有回答我需要的内容.
I have looked through other posts but none seem to answer what I need.
- 我在WebMatrix(ASP.NET)中创建了一个空站点
- 我在VWD 2013中打开了该网站
- 我按了F5键,它可以在诸如 http://local.com:59833/的URL上正常运行ContentPage.cshtml
-
我转到 http://local.com/cscsu_bi/ContentPage.cshtml,并且无法解决以下错误
- I created an empty site in WebMatrix (ASP.NET)
- I opened that site in VWD 2013
- I hit F5 and it runs fine on a URL such as http://local.com:59833/ContentPage.cshtml
I go to http://local.com/cscsu_bi/ContentPage.cshtml and it doesn't work with the error below
"/"应用程序中的服务器错误.
不提供此类页面.
说明:由于明确禁止了您请求的页面类型,因此无法提供.扩展名".cshtml"可能不正确.请查看下面的网址,并确保其拼写正确.
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.
请求的URL:/cscsu_bi/ContentPage.cshtml
Requested URL: /cscsu_bi/ContentPage.cshtml
web.config文件如下
The web.config file is as follows
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="webpages:Enabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
我在Windows 7上.我是否在做错任何明显的事情?
I am on Windows 7. Is there anything obvious I'm doing wrong?
谢谢
推荐答案
我缺少 Microsoft.AspNet.WebPages
NuGet包.安装它解决了我的问题.(此程序包依赖于 Microsoft.Web.Infrastructure
和 Microsoft.Web.Razor
,因此为您包括了它们)
I was missing the Microsoft.AspNet.WebPages
NuGet package. Installing it solved my problem. (This package has dependencies on Microsoft.Web.Infrastructure
and Microsoft.Web.Razor
and thus includes them for you)
如果使用NuGet控制台,只需键入:
If you use the NuGet console, just type:
Install-Package Microsoft.AspNet.WebPages
这篇关于C#和Razor-由于已明确禁止您请求的页面类型,因此无法提供.扩展名".cshtml"可能不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!