IIS防爆preSS(WebMatrix中2)将不会成为.cshtml文件的WebAPI项目(VS10 / WinXP中) [英] IIS Express (WebMatrix 2) won't serve .cshtml files in WebAPI project (VS10/WinXP)
问题描述
我想通过WebMatrix的2.我得到试图index.cshtml浏览(根),当这个错误在WinXP运行的WebAPI项目:
I am trying to run a WebAPI project on WinXP through WebMatrix 2. I'm getting this error when attempting to browse index.cshtml (in the root):
这种类型的网页不提供的。的
"This type of page is not served."
我创造了在Visual Studio 2010中MVC4项目类型下的WebAPI项目,然后设置项目下的IIS防爆preSS运行。
I created a WebAPI project under the MVC4 project type in Visual Studio 2010, then set the project to run under IIS Express.
我已经试过:
在VS创建WebMatrix的网站上的.NET CLR设置是.NET 4.0(集成)。
The .NET CLR settings in the VS-created WebMatrix site is .NET 4.0 (Integrated).
我已经试过玩 runAllManagedModulesForAllRequests
Web.config文件中的设置,没有运气。
I've already tried playing with the runAllManagedModulesForAllRequests
setting in Web.config, no luck.
同时在开发服务器和IIS防爆preSS出现的错误。
The error occurs in both the development server and IIS Express.
我已经重新启动。
然而,的如果我创建了一个网站的通过WebMatrix2 UI,的工作原理。剃刀.cshtml文件通过WebMatrix中加入该网站使就好了。
However, if I create a Site through the WebMatrix2 UI, it works. Razor .cshtml files added to that site through WebMatrix render just fine.
TIA!
推荐答案
成功!
问题是在默认的WebAPI模板的web.config一行:
The problem was a single line in the default WebAPI template web.config:
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" /> <-- BAD!!!!
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
设置,网页:启用
设置为真正
固定的问题,现在我的.cshtml文件。希望这可以帮助别人。
Setting that webpages:Enabled
setting to true
fixed the problem and now my .cshtml files work. Hope this helps others.
这个问题说明了网页:启用
设置:
<一href=\"http://stackoverflow.com/questions/4886095/what-is-the-function-of-webpagesenabled-in-mvc-3-web-config\">what是网页的功能:在MVC 3 web.config中启用
This question explains the webpages:Enabled
setting:
what is the function of webpages:Enabled in MVC 3 web.config
这篇关于IIS防爆preSS(WebMatrix中2)将不会成为.cshtml文件的WebAPI项目(VS10 / WinXP中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!