473,785 Members | 2,919 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Obtaining the Absolute URL of a page

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
nj********@hotm ail.com
http://www.nathansokalski.com/
Sep 8 '08
13 2489
I think what you want is ResolveClientUr l() 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 ResolveClientUr l() and get the absolute path that way.

+++ Rick ---
"Nathan Sokalski" <ns*******@kyle davidgroup.comw rote in message
news:Ot******** ******@TK2MSFTN GP02.phx.gbl...
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 )" <ig************ @gmail.comwrote in
message
news:6b******** *************** ***********@z72 g2000hsb.google groups.com...
On Sep 8, 1:50 pm, "Nathan Sokalski" <nsokal...@kyle davidgroup.com>
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
njsokal...@hot mail.comhttp://www.nathansokal ski.com/

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

Sep 9 '08 #11
No, that still gives me something like "/mydirectory/mypage.aspx", but it
does not include the "http://www.mydomain.co m". I am using code like the
following:

ResolveClientUr l("~/mydirectory/mypage.aspx")

This is what you meant, right? If you have any other ideas (or if you did
mean something else) please let me know. Thanks.

"rstrahl" <ri********@hot mail.comwrote in message
news:C4******** *************** ***********@mic rosoft.com...
>I think what you want is ResolveClientUr l() 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 ResolveClientUr l() and get the absolute path that way.

+++ Rick ---
"Nathan Sokalski" <ns*******@kyle davidgroup.comw rote in message
news:Ot******** ******@TK2MSFTN GP02.phx.gbl...
>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 )" <ig************ @gmail.comwrote in
message
news:6b******* *************** ************@z7 2g2000hsb.googl egroups.com...
On Sep 8, 1:50 pm, "Nathan Sokalski" <nsokal...@kyle davidgroup.com>
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
njsokal...@ho tmail.comhttp://www.nathansokal ski.com/

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


Sep 9 '08 #12
Unfortunately, that does not include the protocol and domain name, it only
includes the path. Any other ideas?

"Hillbilly" <so******@somew here.comwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
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" <ns*******@kyle davidgroup.comw rote in message
news:Ou******** ******@TK2MSFTN GP02.phx.gbl...
>>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
nj********@hotm ail.com
http://www.nathansokalski.com/

Sep 9 '08 #13
Hey Nathan,

Why don't you try the

Request.Url.Get LeftPart(UriPar tial.Authority)

statement for the protocol name, domain name and port part?

Cheers,
Erjan

"Nathan Sokalski" <ns*******@kyle davidgroup.comw rote in message
news:uy******** ******@TK2MSFTN GP02.phx.gbl...
Unfortunately, that does not include the protocol and domain name, it only
includes the path. Any other ideas?

"Hillbilly" <so******@somew here.comwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
>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" <ns*******@kyle davidgroup.comw rote in message
news:Ou******* *******@TK2MSFT NGP02.phx.gbl.. .
>>>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
developmen t. I need the absolute url because it will be getting sent as
part of an email. Thanks.

Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Sep 9 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5709
by: gregl | last post by:
Anyone know how to obtain the true size of the html document's body? The control contains the size that the control was set to. The body object appears to contain the same size. That information must be stored somewhere in order for the scroll bars to be enabled when the body is larger than the container. Also, I have noticed that if I initialize the control with a large size, the vertical scrollbar is disabled, but is still visible,...
3
1601
by: Sir Loin of Beef | last post by:
I have a root directory with 1 subdirectory(myphoto), and 2 files. Inside the myphoto subdirectory, I have 1 html page and another image. Root dir: <myphoto> 01.jpg watermark.php myphoto:
7
21317
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of someone (client) that visits a web site through an anonymous proxy if this person ONLY has JavaScript enabled in their browser? This is NOT a question about PHP, perl, VBScript, Java(.class), or ActiveX. Let us _only_ deal with JavaScript for...
6
1477
by: Pete | last post by:
Hi, I am writing a pre-handler page for aspx pages, in which I want to call a custom method on the code-behind class file for the aspx page. In order to do this I need to somehow get the class full namespace for the codebehind aspx page from the request absolute url that I have in the pre-handler page.
1
1845
by: Terry Mulvany | last post by:
Grettings, Normally I can use Request.RawUrl to get the 'current' page (amongst many other things). But in the case of using a Server.Transfer but the path from the root of the site . So if foo.aspx server.transfer()ed to http://www.domain.com/somefolder/bar.aspx I need '/somefolder/bar.aspx'. Thanks in advance.
12
1328
by: Nathan Sokalski | last post by:
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...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.