Get the full URL for a page

W

Waldy

Hi there,
how do I get the full path for an .ASPX page? I thought the
ResolveURL would do it, but it only seems to return the page name with a
forward slash at the start. I need to send the full external path to remote
users so that they can run the page.
 
M

Mark Rae [MVP]

how do I get the full path for an .ASPX page? I thought the ResolveURL
would do it, but it only seems to return the page name with a forward
slash at the start. I need to send the full external path to remote users
so that they can run the page.

Request.Url.AbsoluteUri
 
W

Waldy

Hi Mark,
thanks for that, but I need the path to another page, not the
current one.
 
M

Mark Rae [MVP]

thanks for that, but I need the path to another page, not the current one.

You should have said so...

string strRelativePath = "home/default.aspx"; // amend as necessary
Uri objUri = new Uri(Request.Url.GetLeftPart(UriPartial.Authority) + "/" +
Request.Url.Segments[1] + strRelativePath);
string strAbsoluteUri = objUri.AbsoluteUri;
 
W

Waldy

Hi Mark,
thanks for that. I was hoping that there was a function for
it. I did this in the end as your code didn't work for me:

String FullURL = Request.Url.AbsoluteUri.Substring(1,
Request.Url.AbsoluteUri.Length - Request.Path.Length);
FullURL += "MyOtherPage.aspx";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top