加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 使ASP.MVC2/VS2010应用程序在IIS 7.5中工作

发布时间:2020-12-15 19:04:58 所属栏目:asp.Net 来源:网络整理
导读:我最近下载了VS2010的beta 2,并开始使用ASP.NET MVC2。最初的开发是用Casini完成的,但现在我想从IIS 7.5(我运行的是Windows 7)运行应用程序。 我已经安装了IIS6元数据库兼容性,我以管理员身份运行VS2010,以便可以从项目设置的“Web”选项卡中使用“创建
我最近下载了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。在我的搜索,这是提供作为一些解决方案的一些similair问题。但对我来说,这还是不行。

我的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,PublicKeyToken=31BF3856AD364E35" />
      <add assembly="System.Web.Mvc,Version=2.0.0.0,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,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,PublicKeyToken=b03f5f7f11d50a3a" />
  </handlers>
  <httpErrors errorMode="Detailed" />
</system.webServer>

解决方法

我刚刚有这个问题,不幸的是这里的修复没有为我工作。

什么工作是运行这:

%windir%Microsoft.NETFramework64v4.0.30319aspnet_regiis.exe -ir

在命令窗口…工作像一个梦想现在!

(所以,是ASP.Net没有安装到IIS默认情况下,当你安装VS2010?)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读