为什么location.hostname不一致?

时间:2013-05-21 10:14:35

标签: javascript asp.net-mvc iis windows-server-2008

我有一个asp.net MVC项目,在我的一个javascripts中,我打电话给location.hostname

当我在MVC上托管我的应用程序时,在我的Windows 7& 8台电脑,我可以打印出localhost/MyApp

但是,当我在Windows Server 2008 R2 PC上托管它时,它只打印出localhost而没有我的虚拟目录名

为什么?以及如何让它显示我的完整网址?

1 个答案:

答案 0 :(得分:1)

您可能想要使用:

window.location.href

window.document.documentURI