【发布时间】:2012-10-02 15:40:31
【问题描述】:
我使用来自 IIS.Net - Understanding Site, Applications and Virtual Directories 的信息在网站下设置了一个 Web 应用程序
下面是他们对申请的评价。
应用程序是一组通过协议(例如 HTTP)交付内容或提供服务的文件。当您在 IIS 中创建应用程序时,应用程序的路径将成为站点 URL 的一部分。
太好了;正是我想要的;但是...对于我在应用程序中拥有的脚本文件、css 和 Web 服务,应用程序路径无法正确解析。
对于http://site_name/application_name
<img src="/Content/images/smiley.png" alt="smiley face" /></a>
解析为
src="/site_name/Content/images/smiley.png"
而不是
src="/application_name/Content/images/smiley.png"
作为一种变通方法,我使用@Url.Content() 助手包装了我正在使用的路径。不是最漂亮的解决方案,但它正在工作。
<img src="@Url.Content("~/Content/images/smiley.png")" alt="smiley face" /></a>
有没有办法在 IIS 中解决这个问题?
【问题讨论】:
标签: asp.net-mvc-3 iis-7.5