无法在 IIS 7.5 上运行 ASP.NET MVC 2 Web 应用程序

无法在 IIS 7.5 上运行 ASP.NET MVC 2 Web 应用程序

问题描述:

我正在尝试在 Windows 7 上的 IIS 下运行 ASP.NET MVC 2 Web 应用程序,但出现 403.14 错误.以下是重现的步骤:

I'm trying to run an ASP.NET MVC 2 web application under IIS on Windows 7, but I get a 403.14 error. Here are the steps to reproduce:

  1. 打开 Visual Studio 2010
  2. 创建一个名为 MvcApplication1 的新 ASP.NET MVC 2 项目
  3. Shift+F5 运行应用程序.您应该看到 http://localhost:{random_port}/ 并且页面将正确呈现.
  4. 单击 MvcApplication1,然后选择属性".转到Web"部分.
  5. 选择使用本地 IIS Web 服务器"并创建一个虚拟目录.
  6. 保存.
  7. Shift+F5 运行应用程序.您应该看到 http://localhost/MvcApplication1/ 和 IIS 错误 HTTP 错误 403.14 - 禁止 Web 服务器被配置为不列出此目录的内容..
  1. Open Visual Studio 2010
  2. Create a new ASP.NET MVC 2 project called MvcApplication1
  3. Shift+F5 to run the app. You should see http://localhost:{random_port}/ and the page will render correctly.
  4. Click on MvcApplication1, and select "Properties". Go to the "Web" section.
  5. Select "Use Local IIS Web server" and create a virtual directory.
  6. Save.
  7. Shift+F5 to run the app. You should see http://localhost/MvcApplication1/ and an IIS error HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory..

很明显,无论出于何种原因,ASP.NET 路由都无法正常工作.

It's clear that for whatever reason, ASP.NET routing is not working correctly.

我已经想到并尝试过的事情:

Things I've already thought of and tried:

  • 已验证在打开或关闭 Windows 功能"中启用了所有 IIS 功能.
  • 已验证默认网站已配置为使用 .NET 4.0
  • 通过 aspnet_regiis -iv4.0.30319 目录中重新分配了 ASP.NET v4 脚本.
  • Verified that all IIS features are enabled in "Turn Windows features on or off".
  • Verified that the default website is configured to use .NET 4.0
  • Reassigned ASP.NET v4 scripmaps via aspnet_regiis -i in the v4.0.30319 directory.

这是最令人惊奇的部分 - 这是在刚刚构建的机器上.Windows 7 x64 Ultimate 的新副本,Visual Studio 2010 Premium 的全新安装,没有其他网站,也没有执行其他工作.

Here's the most amazing part - this is on a just-built machine. New copy of Windows 7 x64 Ultimate, clean install of Visual Studio 2010 Premium, no other websites and no other work performed.

还有什么我可以尝试的吗?

Anything else I can try?

好的,这对我来说已经解决了,通过执行以下操作:

Ok, this is resolved for me, by doing the following:

32位目录c:WindowsMicrosoft.NETFrameworkv4.0.30319中运行aspnet_regiis -i.

此时,我不明白为什么 64 位模式不起作用,但我现在已解锁.希望这对遇到此问题的其他人有所帮助.

At this point, I don't understand why 64-bit mode isn't working, but I'm now unblocked. Hopefully this helps anyone else who is having this issue.