hello guys how r u ?
my question is that , how to get url in c# ?
reply soon
Thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 30, 2012, 10:36 PM
Try this.
string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx
string host = HttpContext.Current.Request.Url.Host;
// localhost
To get the URL of the browser: Request.ServerVariables["URL"]
To get the host name of the url : Request.ServerVariables["SCRIPT_NAME"]
hope this help.
VulpesPosted Jan 30, 2012, 2:04 PM
string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;