HTTP错误403.14 -禁止-发布MVC 4项目时

本文关键字:MVC 项目 -发布 禁止 错误 HTTP | 更新日期: 2023-09-27 18:04:06

这个问题似乎已经被问过/回答过很多次了。它不是。

开发环境:VS 2013和MVC 4, Visual c#。我使用内置的IIS Express来运行应用程序。

当使用Ftp详细信息发布站点时,它显示已成功发布,并且所有文件都存储在wwwroot文件夹中(使用FileZilla检查)

但是当我打开网站时,显示以下错误

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
Things you can try:
If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.
Enable directory browsing using IIS Manager.
    Open IIS Manager.
    In the Features view, double-click Directory Browsing.
    On the Directory Browsing page, in the Actions pane, click Enable.
Verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file.
Detailed Error Information:
Module     DirectoryListingModule
Notification       ExecuteRequestHandler
Handler    StaticFile
Error Code     0x00000000
Requested URL      http://www.infokairali.com:80/
Physical Path      E:'HostingSpaces'infokairali'infokairali.com'wwwroot
Logon Method       Anonymous
Logon User     Anonymous
我已经在IIS中完成了上面提到的所有事情。改变网络。配置文件如
<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true"/>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%'Microsoft.NET'Framework'v4.0.30319'aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%'Microsoft.NET'Framework64'v4.0.30319'aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
</configuration>

,但是同样的错误仍然存在。

HTTP错误403.14 -禁止-发布MVC 4项目时

我怀疑这是路由问题。默认情况下,路由中有一个默认的控制器和动作,比如:

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}"
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

我试着注释掉上面的"defaults"参数,开始得到HTTP 403.14错误。请确保默认设置为有效的控制器和动作