Can u tell me how to get complete web page address in asp.net if i am running home.aspx page? For example, if i am running http://www.mysite.com/default.aspx, then how to get this address from a web page?
Do you want to get the current page's URL programmatically? If so, we can use Request.Url to get information about the URL of the current request.
For example:
protected void Page_Load(object sender, EventArgs e)
{ Uri MyUrl = Request.Url;
Response.Write("URL is " + MyUrl.ToString() + "<br>");
}
I look forward to receiving your test results.
Thomas Sun
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
<div id=ctl00_ctl00_bcr_bcr_PostForm__QuoteText>Can u tell me how to get complete web page address in asp.net if i am running home.aspx page? For example, if i am running http://www.mysite.com/default.aspx, then how to get this address from a web page?</div>
hemal_301080
Member
32 Points
86 Posts
Get URL Address
Jan 19, 2009 12:22 AM|LINK
Hemal Rathod
blacdian
Member
207 Points
52 Posts
Re: Get URL Address
Jan 19, 2009 01:16 AM|LINK
To view or to Post for Data reasons?
Thomas Sun –...
All-Star
64969 Points
5621 Posts
Re: Get URL Address
Jan 21, 2009 07:34 AM|LINK
Hi,
Do you want to get the current page's URL programmatically? If so, we can use Request.Url to get information about the URL of the current request.
For example:
protected void Page_Load(object sender, EventArgs e)
{
Uri MyUrl = Request.Url;
Response.Write("URL is " + MyUrl.ToString() + "<br>");
}
I look forward to receiving your test results.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Get URL Address
Jan 21, 2009 08:04 AM|LINK
This way
Dim strURL As String = Request.Url.AbsoluteUriContact me
hemal_301080
Member
32 Points
86 Posts
Re: Get URL Address
Jan 24, 2009 07:20 AM|LINK
if i want to get the same from a dll in the same project. is there any way?
I tried but it says error 'request is not applicable in this context'
Hemal Rathod
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Get URL Address
Jan 24, 2009 07:54 AM|LINK
you can try this
C#
string url = HttpContext.Current.Request.Url.AbsoluteUri;VB
Dim url As String = HttpContext.Current.Request.Url.AbsoluteUriContact me
hemal_301080
Member
32 Points
86 Posts
Re: Get URL Address
Feb 01, 2009 05:04 AM|LINK
Hemal Rathod
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Get URL Address
Feb 01, 2009 05:10 AM|LINK
Plz mark my post as answer
Contact me
nitishk1127
Member
28 Points
13 Posts
Re: Get URL Address
Sep 26, 2009 08:58 AM|LINK
thanks for ur help with this article..
happy programming