【发布时间】:2015-10-15 04:56:41
【问题描述】:
我正在构建一个 MVC Web 应用程序,它应该响应 a.sub.example.com、b.sub.example.com、c.sub.example.com 等域。我可以弄清楚如何取出 a、b、c 等前缀并相应地创建正确的路由,但我正在努力让 IIS 网络服务器将请求实际转发到同一个网络应用程序。
我按照this 指南让 IIS express 监听另一个地址,在本例中为 sub.example.com,它工作正常。但是,我无法弄清楚如何让它监听该子域的所有子域。当我将浏览器定向到 a.sub.example.com 时,出现错误:
HTTP Error 400. The request hostname is invalid.
我在 hosts 文件中添加了 sub.example.com 和 a.sub.example.com 作为 127.0.0.1 的别名。
我的 applicationhost.config 文件的“站点”条目如下所示:
<site name="MyProject.Web" id="7">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="..." />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:8888:sub.example.com" />
</bindings>
<applicationDefaults applicationPool="Clr2IntegratedAppPool" />
</site>
当我将 'bindingInformation 属性替换为
"*:8888:*.sub.example.com"
正如前面提到的指南所建议的,当我希望 IIS Express 监听多个域时,IIS Express 根本无法启动。
我在这里遗漏了什么明显的东西吗?
【问题讨论】:
-
查看此链接以获取有关使用 MVC 的子域的信息。 csharptechies.blogspot.com/2013/11/…
-
您建议的博文主要是关于如何正确设置mvc路由以使子域链接到区域。据我所知,其中没有关于如何让 IIS express 支持子域的内容。
标签: visual-studio-2013 asp.net-mvc-5 iis-express