【发布时间】:2013-10-02 17:33:12
【问题描述】:
我在默认网站下的 IIS 上托管了一个 MVC 应用程序。所以我可以通过浏览http://localhost/appname来访问应用程序。
我还有一个 URL 重写模块,如果输入的 URL 是这样的,它会返回相同的主页
http://localhost/appname/request/*
我想在我的 index.html 文件中获取路径 url (http://localhost/appname/)。我正在使用剃刀语法。因此,如果我将网站托管在不同的路径或不同的应用名称下,我的 ajax 查询和 css 不会受到影响。
如何在 index.html 文件的 javascript 中获取 http://localhost/appname。
【问题讨论】:
-
RequestContext..ApplicationPath 为 razor , window.location.hostname 为主机名
标签: asp.net asp.net-mvc razor