2010-08-18 67 views

回答

4
// Use the Uri constructor to form a URL relative to the current page 
Uri linkUri = new Uri(HttpContext.Current.Request.Url, "/Contract/Details/" + this.ContractId.ToString()); 
string link = linkUri.ToString(); 
+0

这是正确的答案。 – arame3333 2010-08-18 10:48:28

4

试试这个:

string url = HttpContext.Current.Request.Url.AbsoluteUri; 
+0

这将返回当前请求URL,也许这不是“/ Contract/Details/1” – 2010-08-18 10:31:34

+0

这是不正确的。安东尼奥和蒂姆是对的。 – arame3333 2010-08-18 10:51:45

0

Uri base = new Uri(“http://localhost:1234/”;); Uri file = new Uri(host,“/ Contract/Details /”+ this.ContractId.ToString());

string URL = file.AbsoluteUri;

+0

蒂姆罗宾逊的答案是更好的因为他使用当前的请求主机 – 2010-08-18 10:30:17

相关问题