ASP.NET MVC部署的应用程序找不到视图(HTTP 403) [英] ASP.NET MVC Deployed application can't find views (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.
到目前为止,我已经尝试过:
- 已验证 .NET Framework 4.5 通过按照此处。
- 使用 添加应用程序在IIS管理器树中创建一个新节点。
- 使用
aspnet_regiis.exe
升级应用程序节点,如此有用的帖子。 - 将应用程序设置为允许匿名身份验证,以确保问题不是由身份验证错误引起的。
- 确认服务器上是否存在我的
Views
文件夹和内容,如 。 - 试图通过复制 我的整个视觉工作室进行部署
- 尝试通过右键单击并从Visual Studio 2013解决方案资源管理器的项目节点中选择 Publish 进行部署。选择在发布之前删除所有现有文件。我在有和没有发布期间预编译的情况下都这样做。
- 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>
此外,如果要对自己的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屋!