Jer*_*len 26 asp.net-mvc iis-7.5 visual-studio-2010-beta-2
我最近下载了VS2010的beta 2并开始使用ASP.NET MVC2.最初的开发是使用Casini完成的,但现在我想从IIS 7.5运行应用程序(我正在运行Windows 7).我已经安装了IIS6配置数据库兼容性,我以管理员身份运行VS2010,因此我可以使用项目设置的"Web"选项卡中的"创建虚拟目录"按钮.这在IIS中创建了Web应用程序条目,但它不起作用.
当我转到主页面(http:// localhost/MyMvcApp /)时,我收到HTTP 403错误.当我直接进入其中一个子页面(http:// localhost/MyMvcApp/Home /)时,我得到一个HTTP 404.
所以我想由于某种原因URL路由不起作用.我已经将UrlRouting添加为web.config的模块和处理程序.在我的搜索中,这是一些类似问题的解决方案.但对我来说,这仍然无效.
我的web.config有趣的部分是这样的:
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
<httpHandlers>
<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler" />
</httpHandlers>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" >
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="MvcHttpHandler" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler" />
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<httpErrors errorMode="Detailed" />
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
Pau*_*aul 49
我刚刚遇到这个问题,不幸的是,这里的修复对我不起作用.
做了什么工作:
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
Run Code Online (Sandbox Code Playgroud)
在命令窗口......现在就像一场梦!
(那么,安装VS2010时默认情况下ASP.Net是否未安装到IIS中?)
Jer*_*len 26
经过更多检查和尝试后,我在"打开或关闭Windows功能"对话框中注意到"HTTP错误"和"HTTP重定向"丢失了.这很奇怪,因为据我所知,这是由Microsoft Web Platform Installer自动安装的.在任何情况下,"HTTP重定向"在使用MVC时似乎都是需要的功能.所以在我安装它之后,一切似乎都很完美.
将其添加到您的web.config文件中:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!-- rest of config -->
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29632 次 |
| 最近记录: |