ASP.NET MVC部署的应用程序找不到视图(HTTP 403) [英] ASP.NET MVC Deployed application can't find views (HTTP 403)

查看:125
本文介绍了ASP.NET MVC部署的应用程序找不到视图(HTTP 403)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将第一个MVC应用程序部署到现有的生产服务器。该应用程序在Visual Studio调试模式下工作,但是在服务器上,如果尝试调用主路径,则会收到HTTP 403错误,除非在IIS中启用目录浏览,在这种情况下,您会看到目录的内容

I am attempting to deploy the first MVC application to an existing production server. The application works in Visual Studio debug mode, but on the server, if I try to call up my home path I get an HTTP 403 error unless I enable directory browsing in IIS, in which case I see the contents of the directory, as you might expect.

服务器正在运行Windows Server 2008,并且与我的开发计算机位于同一域中。

The server is running Windows Server 2008 and is on the same domain as my development computer.

到目前为止,我已经尝试过:

  • Verified that .NET framework 4.5 has been installed on the server by checking the registry as described here.
  • Created a new node in the IIS Manager tree using "Add Application".
  • Upgraded the application node with aspnet_regiis.exe as described in this helpful post.
  • Set the application to allow Anonymous authentication to make sure the problem wasn't being caused by authentication errors.
  • Confirmed the presence of my Views folder and contents on the server as described here.
  • Attempted to deploy by copying my entire visual studio project to the application folder on the server.
  • Attempted to deploy by right-clicking and selecting Publish from the project node in the Visual Studio 2013 solution explorer. Selected "Delete all existing files prior to publish." I did this both with and without "Precompile during publishing".

有什么想法下一步要检查吗?

Any ideas what to check next?

推荐答案

我终于通过更改Web.config文件并在下面引用UrlRoutingModule的两行添加了代码,解决了该问题。 不要添加 preCondition = managedHandler 属性!

I finally fixed the problem by changing my Web.config file, adding the two lines below that reference the UrlRoutingModule. Do not add the preCondition="managedHandler" attribute!

<configuration>
  <system.webServer>
    <modules>

      <remove name="UrlRoutingModule-4.0"/>
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" />

    </modules>
  </system.webServer>
</configuration>

Thomas Marquardt的这篇有用的帖子

此外,如果要对自己的MVC路由进行故障排除,请务必检查Ferruccio的回答并确定。

Also, if you're troubleshooting your own MVC routing, be sure to check the answers posted by Ferruccio and stead.

这篇关于ASP.NET MVC部署的应用程序找不到视图(HTTP 403)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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