虚拟目录导航到http:// localhost/MyWebsite而不是http:// localhost:8080

虚拟目录导航到http:// localhost/MyWebsite而不是http:// localhost:8080

问题描述:

我已经将ASP.NET MVC 4应用程序部署到了我在IIS 7.5中创建的新站点,该站点已绑定到端口8080.我可以通过导航到http://localhost:8080来达到目的,但我想通过http://localhost/MyWebsite来达到目的。虚拟目录导航到http:// localhost/MyWebsite而不是http:// localhost:8080

我在我的网站上添加了一个虚拟目录,它指向“C:\inetput\wwwroot\MyWebsite\”。然而,当我浏览到http://localhost/MyWebsite,我提出了一个配置错误:

"It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS."

这里是我的IIS层次的样子(这是一个演示,因为我有我的工作在服务器上没有互联网接入) 。

enter image description here

我有两个问题:

  1. 为什么会出现这个错误?
  2. 这是实现我想要的最好方法吗?在网站下面有文件和文件夹列表,然后再次在虚拟目录下面看起来很麻烦。如果有更好的做法,那么请告诉!
+0

使MyWebsite文件夹成为应用程序(右键单击,转换为应用程序) – Naner 2015-02-10 17:12:11

虚拟目录不能执行脚本,理由你得到这个错误。您需要将MyWebsite文件夹设置为应用程序。另外,您不一定要必须为您的网站创建一个单独的网站,您可以使用默认网站并在那里创建一个应用程序MyWebsite(它可能不那么令人困惑?)。