【发布时间】:2012-07-30 16:45:05
【问题描述】:
我正在使用这样的方法来获取我的应用程序的 URL 路径:
string strPathAndQuery = HttpContext.Request.Url.PathAndQuery;
string strUrl = HttpContext.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/");
这应该是指向当前 URL 的路径。
问题是,我的实时服务器将应用程序作为 IIS 服务器内的应用程序(文件夹)运行。因此,在测试 a 时,我会得到如下 URL:
http://localhost/Survey/Create
我得到了生活:
http://testurl.com/Survey/Create
当我需要实时服务器时:
http://testurl.com/SurveyApp/Survey/Create
SurveyApp 是在 IIS 中存储应用程序的文件夹。有没有一种方法可以让我获得控制器所在位置的 URL,而不管物理位置如何?
【问题讨论】:
标签: c# asp.net-mvc-3 iis-7 asp.net-mvc-routing