tags:

views:

12775

answers:

3

Hello ,

Can anyone help out me in getting the URL of the current working page of asp .net C#,...

thank you

+27  A: 

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
Canavar
+1  A: 

if you just want the part between http:// and the first slash

string url = Request.Url.Host;

would return stackoverflow.com if called from this page

Here's the complete breakdown

roman m
A: 

Make use of

System.Web.HttpContext

K10