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

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 使ASP.MVC2/VS2010应用程序在IIS 7.5中工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我最近下载了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的有趣的部分看起来像这样:

  1. <system.web>
  2. <compilation debug="true" targetFramework="4.0">
  3. <assemblies>
  4. <add assembly="System.Web.Abstractions,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
  5. <add assembly="System.Web.Routing,PublicKeyToken=31BF3856AD364E35" />
  6. <add assembly="System.Web.Mvc,Version=2.0.0.0,PublicKeyToken=31BF3856AD364E35" />
  7. </assemblies>
  8. </compilation>
  9. <authentication mode="Forms">
  10. <forms loginUrl="~/Account/logon" timeout="2880" />
  11. </authentication>
  12. <membership>
  13. <providers>
  14. <clear />
  15. <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="/" />
  16. </providers>
  17. </membership>
  18. <profile>
  19. <providers>
  20. <clear />
  21. <add name="AspNetsqlProfileProvider" type="System.Web.Profile.sqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  22. </providers>
  23. </profile>
  24. <roleManager enabled="false">
  25. <providers>
  26. <clear />
  27. <add name="AspNetsqlRoleProvider" type="System.Web.Security.sqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
  28. <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  29. </providers>
  30. </roleManager>
  31. <pages>
  32. <namespaces>
  33. <add namespace="System.Web.Mvc" />
  34. <add namespace="System.Web.Mvc.Ajax" />
  35. <add namespace="System.Web.Mvc.Html" />
  36. <add namespace="System.Web.Routing" />
  37. </namespaces>
  38. </pages>
  39. <httpHandlers>
  40. <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler" />
  41. </httpHandlers>
  42. <customErrors mode="Off" />
  43. </system.web>
  44. <system.webServer>
  45. <validation validateIntegratedModeConfiguration="false" />
  46. <modules runAllManagedModulesForAllRequests="true" >
  47. <remove name="UrlRoutingModule"/>
  48. <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,PublicKeyToken=31BF3856AD364E35" />
  49. </modules>
  50. <handlers>
  51. <remove name="MvcHttpHandler" />
  52. <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler" />
  53. <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler,System.Web,PublicKeyToken=b03f5f7f11d50a3a" />
  54. </handlers>
  55. <httpErrors errorMode="Detailed" />
  56. </system.webServer>

解决方法

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

什么工作是运行这:

  1. %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

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

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

猜你在找的asp.Net相关文章