获得一个ASP.MVC2 / VS2010应用程序在IIS 7.5工作 [英] Getting an ASP.MVC2/VS2010 application to work in IIS 7.5

查看:101
本文介绍了获得一个ASP.MVC2 / VS2010应用程序在IIS 7.5工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载VS2010的Beta 2中,并开始与ASP.NET MVC2玩。最初的发展与卡西尼做的,但现在我想从运行IIS 7.5的应用程序(我运行Windows 7)。
我安装了IIS6兼容性配置数据库和我运行VS2010以管理员身份,所以我可以从项目设置的网络选项卡中使用创建虚拟目录按钮。
这创造了在IIS中的Web应用程序条目,但它不能正常工作。

当我去的主网页(的http://本地主机/ MyMvcApp / )我得到一个HTTP 403错误。当我直接去子页面之一(的http://本地主机/ MyMvcApp /主页/ )我得到一个HTTP 404。

所以我想由于某些原因,URL路由不工作。
我已经添加UrlRouting作为模块和处理程序的Web.config。在我的搜索这是献为一些similair问题的解决方案。但对我来说,这仍然是行不通的。

我的web.config的有趣的部分looke是这样的:

 <&的System.Web GT;
  <编译调试=真targetFramework =4.0>
    <&集会GT;
      <添加组件=System.Web.Abstractions,版本= 4.0.0.0,文化=中性公钥= 31BF3856AD364E35/>
      <添加组件=System.Web.Routing,版本= 4.0.0.0,文化=中性公钥= 31BF3856AD364E35/>
      <添加组件=System.Web.Mvc,版本= 2.0.0.0,文化=中性公钥= 31BF3856AD364E35/>
    < /组件>
  < /编译>
  <身份验证模式=表格>
    <形式loginUrl =〜/帐号/登录超时=2880/>
  < /认证>
  <会员和GT;
    <供应商>
      <清/>
      <添加名称=AspNetSqlMembershipProviderTYPE =System.Web.Security.SqlMembershipProvider的connectionStringName =ApplicationServicesenablePasswordRetrieval =假enablePasswordReset设置=真requiresQuestionAndAnswer =假requiresUniqueEmail =假maxInvalidPasswordAttempts =5minRequiredPasswordLength =6minRequiredNonalphanumericCharacters =0passwordAttemptWindow =10的applicationName =//>
    < /供应商>
  < /会员>
  <型材>
    <供应商>
      <清/>
      <添加名称=AspNetSqlProfileProviderTYPE =System.Web.Profile.SqlProfileProvider的connectionStringName =ApplicationServices的applicationName =//>
    < /供应商>
  < / profile文件>
  < roleManager启用=false的>
    <供应商>
      <清/>
      <添加名称=AspNetSqlRoleProviderTYPE =System.Web.Security.SqlRoleProvider的connectionStringName =ApplicationServices的applicationName =//>
      <添加名称=AspNetWindowsTokenRoleProviderTYPE =System.Web.Security.WindowsTokenRoleProvider的applicationName =//>
    < /供应商>
  < / roleManager>
  <网页和GT;
    <&命名空间GT;
      <添加命名空间=System.Web.Mvc/>
      <添加命名空间=System.Web.Mvc.Ajax/>
      <添加命名空间=System.Web.Mvc.Html/>
      <添加命名空间=System.Web.Routing/>
    < /命名空间>
  < /页>
  <&HttpHandlers的GT;
    <添加动词=*路径=* MVC。验证=假TYPE =System.Web.Mvc.MvcHttpHandler/>
  < / HttpHandlers的>
  <的customErrors模式=关/>
< /system.web>
< system.webServer>
  <验证validateIntegratedModeConfiguration =FALSE/>
  <模块runAllManagedModulesForAllRequests =真正的>
    <清除NAME =UrlRoutingModule/>
    <添加名称=UrlRoutingModuleTYPE =System.Web.Routing.UrlRoutingModule,System.Web.Routing,版本= 4.0.0.0,文化=中性公钥= 31BF3856AD364E35/>
  < /模块>
  <&处理GT;
    <清除NAME =MvcHttpHandler/>
    <添加名称=MvcHttpHandlerpreCondition =integratedMode动词=*路径=* MVC。TYPE =System.Web.Mvc.MvcHttpHandler/>
    <添加名称=UrlRoutingHandlerpreCondition =integratedMode动词=*路径=UrlRouting.axdTYPE =System.Web.HttpForbiddenHandler,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/>
  < /处理器>
  < httpErrors errorMode =详细/>
< /system.webServer>


解决方案

更​​多的检查之后,并试图我在看到启用Windows功能打开或关闭对话HTTP错误和HTTP重定向不翼而飞。
因为据我记得这是由微软Web平台安装程序自动安装这个很奇怪。
与MVC工作时,在任何情况下,HTTP重定向似乎是一个需要对有功能。所以之后我安装了它的一切似乎很好地工作。

I've recently downloaded beta 2 of VS2010 and started playing with ASP.NET MVC2. Initial development was done with Casini, but now I wanted to run the application from IIS 7.5 (I'm running Windows 7). I've installed the IIS6 metabase compatiblity and I run VS2010 as administrator so I can use the "Create Virtual Directory" button from the "Web" tab of the project settings. This created the web application entry in IIS, but it doesn't work.

When I go to the main page (http://localhost/MyMvcApp/) I get a HTTP 403 error. When I go directly to one of the sub-pages (http://localhost/MyMvcApp/Home/) I get an HTTP 404.

So I guess for some reason the URL routing isn't working. I've already added UrlRouting as a module and a handler to the web.config. In my searches this is offered as a solution for some similair problems. But for me this still doesn't work.

The interesting part of my web.config looke like this:

<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>

解决方案

After more checking and trying I noticed in the "Turn Windows features on or off" dialog that "HTTP Errors" and "HTTP Redirection" were missing. This is strange because as far as I can remember this was installed automatically by the Microsoft Web Platform Installer. In any case "HTTP Redirection" seemed like a need-to-have feature when working with MVC. So after I installed it everything seemed to work perfectly.

这篇关于获得一个ASP.MVC2 / VS2010应用程序在IIS 7.5工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆