在将ASP.NET MVC 5部署到IIS服务器时出现问题

3
我正在尝试将我的网站发布/部署到iis 7服务器上。在Visual Studio中单击运行时,它完美地工作。我按照教程使用Web Deploy将文件部署到服务器上,文件已经在那里,一切似乎都很正常。但是当我打开网站链接:http://10.0.0.12:8000/时,出现以下错误:HTTP Error 403.14 - ForbiddenThe Web server is configured to not list the contents of this directory. 我已经提供了管理员凭据,并检查了是否配置了默认页面。我做错了什么?这里是我的配置文件:
<configuration>
<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
 <appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5.1" />
 <httpRuntime targetFramework="4.5.1" />
</system.web>
<system.webServer>
<modules>
  <remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
  </dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  <providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  </providers>
 </entityFramework>
</configuration>

你使用的IIS版本是什么? - Dillen Meijboom
你在机器上安装了MVC吗?你在web.config中正确设置了所有处理程序吗?正确的应用程序是否在正确的路径下运行?等等。 - Dillen Meijboom
在机器上安装MVC?请详细说明?根据:https://dev59.com/EmIj5IYBdhLWcg3wuHTP,您不需要安装。 - Zapnologica
2个回答

9

需要尝试和检查的事项:

  1. Set the runAllManagedModulesForAllRequests="true"attribute on the <modules> section in your web.config:

    <modules runAllManagedModulesForAllRequests="true">
    
  2. The website is configured to use an Application Pool using ASP.NET 4.0, Integrated Pipeline mode
  3. ASP.NET 4.0 is registered in IIS. Use the following command to ensure this is the case (might need to adjust the Framework64 folder with Framework if you are on a 32 bit server):

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -ir
    

1
天哪,我不知道为什么这么难。你的第三点解决了我的问题。 - David Grant
非常感谢您,Drain your #3 让我开心。👍 - Bahaa Hany

1
请前往网站物理部署位置的web.config文件并打开它。您会在xml文件的末尾附近找到一个xml标签,内容如下:

 <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
               ....
    </handlers>
  <!--ENTER THE CODE HERE-->
  </system.webServer>

在给定的位置添加以下代码片段,保存并刷新您的网站。
<modules runAllManagedModulesForAllRequests="true">

同时尝试删除已有的其他标签!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接