若是一个本地地址:http://localhost:51771/ADMIN/Mobile_Web/index.aspxweb
部署到服务器上就变成了这个地址:http://demo.nowwin.cn/mobile_web/index.aspx。那么该如何动态获取呢。服务器
咱们能够找出规律,无论前面的地址是什么,文件目录都在mobile_web/目录下。则能够按照下面这种方式url
int index = Request.Url.ToString().IndexOf("://");
index = Request.Url.ToString().IndexOf("/", index + 3);
index = Request.Url.ToString().IndexOf("/", index + 1);
//index = Request.Url.ToString().IndexOf("/", index + 1);//看你目录的层次了
string ff = Request.Url.ToString().Substring(0, index);
string url = ff + "/index.aspx";部署
但愿你们给出更好的方法!get