Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Obtaining the Absolute URL of a page

Reply
Thread Tools

Obtaining the Absolute URL of a page

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-08-2008
I have a page in my site that I need the absolute url of. Is there a
function in .NET to which you can pass a relative url or something such as
"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
because at the moment I do not know what the domain name (or if there is the
possibility of the site going in a subdirectory) where the site will
eventually exist. Also, this will make it easier to test during development.
I need the absolute url because it will be getting sent as part of an email.
Thanks.

Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Kalpesh
Guest
Posts: n/a
 
      09-08-2008
Does Request.Url help?

Kalpesh

On Sep 8, 10:50*am, "Nathan Sokalski" <(E-Mail Removed)>
wrote:
> I have a page in my site that I need the absolute url of. Is there a
> function in .NET to which you can pass a relative url or something such as
> "~/mydirectory/mypage.aspx" which will return an absolute url? I need this
> because at the moment I do not know what the domain name (or if there is the
> possibility of the site going in a subdirectory) where the site will
> eventually exist. Also, this will make it easier to test during development.
> I need the absolute url because it will be getting sent as part of an email.
> Thanks.
>
> Nathan Sokalski
> (E-Mail Removed)://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      09-08-2008
On Sep 8, 1:50*pm, "Nathan Sokalski" <(E-Mail Removed)>
wrote:
> I have a page in my site that I need the absolute url of. Is there a
> function in .NET to which you can pass a relative url or something such as
> "~/mydirectory/mypage.aspx" which will return an absolute url? I need this
> because at the moment I do not know what the domain name (or if there is the
> possibility of the site going in a subdirectory) where the site will
> eventually exist. Also, this will make it easier to test during development.
> I need the absolute url because it will be getting sent as part of an email.
> Thanks.
>
> Nathan Sokalski
> (E-Mail Removed)://www.nathansokalski.com/


You can get your current absolute URL by using
Request.Url.AbsoluteUri. you will have to modify the part different
from the current relative url to the one that you want to return.

 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-08-2008
No, I am looking for a function that will get me the absolute URL of a page
other than the page I am currently on. I want to avoid the need to use
string manipulation, which would be required with anything in the Request
object. Any other ideas?

"Kalpesh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Does Request.Url help?

Kalpesh

On Sep 8, 10:50 am, "Nathan Sokalski" <(E-Mail Removed)>
wrote:
> I have a page in my site that I need the absolute url of. Is there a
> function in .NET to which you can pass a relative url or something such as
> "~/mydirectory/mypage.aspx" which will return an absolute url? I need this
> because at the moment I do not know what the domain name (or if there is
> the
> possibility of the site going in a subdirectory) where the site will
> eventually exist. Also, this will make it easier to test during
> development.
> I need the absolute url because it will be getting sent as part of an
> email.
> Thanks.
>
> Nathan Sokalski
> (E-Mail Removed)://www.nathansokalski.com/



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-08-2008
That is what I am currently doing, however, I think it would be nice to have
a method that can get me the absolute url of another page. Does such a
function exist, or will I need to write it myself? Thanks.

"Ignacio Machin ( .NET/ C# MVP )" <(E-Mail Removed)> wrote in
message
news:(E-Mail Removed)...
On Sep 8, 1:50 pm, "Nathan Sokalski" <(E-Mail Removed)>
wrote:
> I have a page in my site that I need the absolute url of. Is there a
> function in .NET to which you can pass a relative url or something such as
> "~/mydirectory/mypage.aspx" which will return an absolute url? I need this
> because at the moment I do not know what the domain name (or if there is
> the
> possibility of the site going in a subdirectory) where the site will
> eventually exist. Also, this will make it easier to test during
> development.
> I need the absolute url because it will be getting sent as part of an
> email.
> Thanks.
>
> Nathan Sokalski
> (E-Mail Removed)://www.nathansokalski.com/


You can get your current absolute URL by using
Request.Url.AbsoluteUri. you will have to modify the part different
from the current relative url to the one that you want to return.


 
Reply With Quote
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      09-08-2008
On Sep 8, 4:06*pm, "Nathan Sokalski" <(E-Mail Removed)>
wrote:
> That is what I am currently doing, however, I think it would be nice to have
> a method that can get me the absolute url of another page. Does such a
> function exist, or will I need to write it myself? Thanks.
>
> "Ignacio Machin ( .NET/ C# MVP )" <(E-Mail Removed)> wrote in
> messagenews:(E-Mail Removed)..com...
> On Sep 8, 1:50 pm, "Nathan Sokalski" <(E-Mail Removed)>
> wrote:
>
> > I have a page in my site that I need the absolute url of. Is there a
> > function in .NET to which you can pass a relative url or something such as
> > "~/mydirectory/mypage.aspx" which will return an absolute url? I need this
> > because at the moment I do not know what the domain name (or if there is
> > the
> > possibility of the site going in a subdirectory) where the site will
> > eventually exist. Also, this will make it easier to test during
> > development.
> > I need the absolute url because it will be getting sent as part of an
> > email.
> > Thanks.

>
> > Nathan Sokalski
> > (E-Mail Removed)://www.nathansokalski.com/

>
> You can get your current absolute URL by using
> Request.Url.AbsoluteUri. you will have to modify the part different
> from the current relative url to the one that you want to return.


Why don't you post your question in the ASPNET NG?
 
Reply With Quote
 
Hillbilly
Guest
Posts: n/a
 
      09-08-2008
Try ResolveUrl("~/dir/filename.asp") which will append the root path of the
domain to the virtual path regardless of where the page is requested and
compiled.



"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:Oug$(E-Mail Removed)...
>I have a page in my site that I need the absolute url of. Is there a
>function in .NET to which you can pass a relative url or something such as
>"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
>because at the moment I do not know what the domain name (or if there is
>the possibility of the site going in a subdirectory) where the site will
>eventually exist. Also, this will make it easier to test during
>development. I need the absolute url because it will be getting sent as
>part of an email. Thanks.
>
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>


 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-08-2008
I have tried that, but it only gives the path, the domain name and protocol
are not included. For example, it would return something like
/mydirectory/mypage.aspx when I am looking for
http://www.mydomain.com/mydirectory/mypage.aspx. Any other ideas?
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Hillbilly" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Try ResolveUrl("~/dir/filename.asp") which will append the root path of
> the domain to the virtual path regardless of where the page is requested
> and compiled.
>
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:Oug$(E-Mail Removed)...
>>I have a page in my site that I need the absolute url of. Is there a
>>function in .NET to which you can pass a relative url or something such as
>>"~/mydirectory/mypage.aspx" which will return an absolute url? I need this
>>because at the moment I do not know what the domain name (or if there is
>>the possibility of the site going in a subdirectory) where the site will
>>eventually exist. Also, this will make it easier to test during
>>development. I need the absolute url because it will be getting sent as
>>part of an email. Thanks.
>>
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      09-08-2008
In case you didn't notice, I did post it to
microsoft.public.dotnet.framework.aspnet.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Ignacio Machin ( .NET/ C# MVP )" <(E-Mail Removed)> wrote in
message
news:(E-Mail Removed)...
On Sep 8, 4:06 pm, "Nathan Sokalski" <(E-Mail Removed)>
wrote:
> That is what I am currently doing, however, I think it would be nice to
> have
> a method that can get me the absolute url of another page. Does such a
> function exist, or will I need to write it myself? Thanks.
>
> "Ignacio Machin ( .NET/ C# MVP )" <(E-Mail Removed)> wrote in
> messagenews:(E-Mail Removed)...
> On Sep 8, 1:50 pm, "Nathan Sokalski" <(E-Mail Removed)>
> wrote:
>
> > I have a page in my site that I need the absolute url of. Is there a
> > function in .NET to which you can pass a relative url or something such
> > as
> > "~/mydirectory/mypage.aspx" which will return an absolute url? I need
> > this
> > because at the moment I do not know what the domain name (or if there is
> > the
> > possibility of the site going in a subdirectory) where the site will
> > eventually exist. Also, this will make it easier to test during
> > development.
> > I need the absolute url because it will be getting sent as part of an
> > email.
> > Thanks.

>
> > Nathan Sokalski
> > (E-Mail Removed)://www.nathansokalski.com/

>
> You can get your current absolute URL by using
> Request.Url.AbsoluteUri. you will have to modify the part different
> from the current relative url to the one that you want to return.


Why don't you post your question in the ASPNET NG?


 
Reply With Quote
 
rstrahl
Guest
Posts: n/a
 
      09-09-2008
I think what you want is ResolveClientUrl() which will generate a fully
qualified URL instead of a relative URL.

You should be able to create a relative URL (~/path/sompage.aspx) and pass
that to ResolveClientUrl() and get the absolute path that way.

+++ Rick ---


"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> That is what I am currently doing, however, I think it would be nice to
> have a method that can get me the absolute url of another page. Does such
> a function exist, or will I need to write it myself? Thanks.
>
> "Ignacio Machin ( .NET/ C# MVP )" <(E-Mail Removed)> wrote in
> message
> news:(E-Mail Removed)...
> On Sep 8, 1:50 pm, "Nathan Sokalski" <(E-Mail Removed)>
> wrote:
>> I have a page in my site that I need the absolute url of. Is there a
>> function in .NET to which you can pass a relative url or something such
>> as
>> "~/mydirectory/mypage.aspx" which will return an absolute url? I need
>> this
>> because at the moment I do not know what the domain name (or if there is
>> the
>> possibility of the site going in a subdirectory) where the site will
>> eventually exist. Also, this will make it easier to test during
>> development.
>> I need the absolute url because it will be getting sent as part of an
>> email.
>> Thanks.
>>
>> Nathan Sokalski
>> (E-Mail Removed)://www.nathansokalski.com/

>
> You can get your current absolute URL by using
> Request.Url.AbsoluteUri. you will have to modify the part different
> from the current relative url to the one that you want to return.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative URL to an absolute URL? John Nagle Javascript 3 02-26-2008 04:33 PM
Response.Redirect() converts relative URL to absolute URL =?Utf-8?B?UGF1bCBCb25mYW50aQ==?= ASP .Net 2 04-25-2006 01:07 AM
Relative URL's to absolute URL's function ? wl ASP .Net 1 07-14-2004 10:28 AM
Invalid URL form or fully-qualified absolute URL was used. Use relative URLs Rudi Ahlers ASP General 11 04-11-2004 03:17 PM
Obtaining class namespace from absolute url request string Pete ASP .Net 4 10-21-2003 04:28 PM



Advertisments