hello guys how r u ?
my question is that , how to get url in c# ?
reply soon
Thanks.
How to get URL in c# ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 30, 2012, 9:04 AM EST
string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 30, 2012, 5:36 PM EST
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.