473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

URL of requested page

In the Page_Load() event, what Class, method do I use to retrieve the URL of
the current aspx page?

Thanks for any comments\information.
--
Gary Larimer
Aug 9 '08 #1
6 1400
"Gary Larimer" <Ga*********@discussions.microsoft.comwrote in message
news:0F**********************************@microsof t.com...
In the Page_Load() event, what Class, method do I use to retrieve the URL
of
the current aspx page?
Everything you need is found in the Request.Url class, specifically its
AbsoluteUri property...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 9 '08 #2
Request.Url.ToString

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Gary Larimer" <Ga*********@discussions.microsoft.comwrote in message
news:0F**********************************@microsof t.com...
In the Page_Load() event, what Class, method do I use to retrieve the URL of
the current aspx page?

Thanks for any comments\information.
--
Gary Larimer

Aug 9 '08 #3
Thanks Mark and Juan.
--
Gary Larimer
"Gary Larimer" wrote:
In the Page_Load() event, what Class, method do I use to retrieve the URL of
the current aspx page?

Thanks for any comments\information.
--
Gary Larimer
Aug 9 '08 #4
Response.Write(Request.RawUrl);

"Gary Larimer" <Ga*********@discussions.microsoft.comдÈëÏûÏ¢
news:0F**********************************@microsof t.com...
In the Page_Load() event, what Class, method do I use to retrieve the URL
of
the current aspx page?

Thanks for any comments\information.
--
Gary Larimer

Aug 10 '08 #5
re:
!Response.Write(Request.RawUrl);

That's incorrect.

Request.RawUrl returns a relative url, not an absolute url.
Request.RawUrl example : /virtualdirectory/requestrawurl.aspx

Request.Url.ToString returns the fully qualified url.
Request.Url.ToString example : http://www.server.com/virtualdirectory/requesturl.aspx


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"amandag" <am*********@hotmail.comwrote in message news:uj****************@TK2MSFTNGP06.phx.gbl...
Response.Write(Request.RawUrl);

"Gary Larimer" <Ga*********@discussions.microsoft.comдÈëÏûÏ¢
news:0F**********************************@microsof t.com...
>In the Page_Load() event, what Class, method do I use to retrieve the URL of
the current aspx page?

Thanks for any comments\information.
--
Gary Larimer


Aug 10 '08 #6
Juan T. Llibre wrote:
re:
!Response.Write(Request.RawUrl);

That's incorrect.

Request.RawUrl returns a relative url, not an absolute url.
Request.RawUrl example : /virtualdirectory/requestrawurl.aspx

Request.Url.ToString returns the fully qualified url.
Request.Url.ToString example : http://www.server.com/virtualdirectory/requesturl.aspx
Well, to be fair the OP actually didn't specify that he wanted an
absolute url.

There is another difference that should be adressed, though. The RawUrl
property contains the URL that the request from the user contains, while
the Url property contains the URL of the page actually handling the
request. Those might not be the same if you for example use the
HttpContext.RewritePath or HttpServer.Transfer methods.

Which one is better, depends on what information the OP really is after.
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"amandag" <am*********@hotmail.comwrote in message news:uj****************@TK2MSFTNGP06.phx.gbl...
>Response.Write(Request.RawUrl);

"Gary Larimer" <Ga*********@discussions.microsoft.comдÈëÏûÏ¢
news:0F**********************************@microso ft.com...
>>In the Page_Load() event, what Class, method do I use to retrieve the URL of
the current aspx page?

Thanks for any comments\information.
--
Gary Larimer


--
Göran Andersson
_____
http://www.guffa.com
Aug 11 '08 #7

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

Similar topics

1
by: adrianTNT | last post by:
Hello, can anyone help me with this? I am new to PHP. I would like to load a variable from a php file, the php script should only give the variable if it was requested by a page on my site. the...
2
by: Dica | last post by:
i need to add a function to body's onUnload to see which URL has been requested. if it isn't the same as the current page, i want to ask the user if they would like to save their changes first. i...
3
by: Peter Theill | last post by:
Hi, I'm trying to include the content of a request into an Xml document: if (System.Web.HttpContext.Current.Session != null) { XmlDocument d = new XmlDocument(); d.Load(new...
2
by: Nobody | last post by:
If I request: http://www.test.com/ which is implictly: http://www.test.com/index.aspx Request.Url contains the index.aspx portion regardless of whether or not the client requested the...
1
by: SMG | last post by:
Hi All, My Send mail system was working very fine, today suddenly it started giving me following error. Can any one suggest why this is happening so. I am using system.Web.Mail "The requested...
3
by: bfprog | last post by:
Using IBM iSeries client access OLEDB provider to connect to DB2 on AS/400, but cannot create connection using .NET web app. Using following code: Dim cnTest As New...
2
by: CathieC | last post by:
I have deployed an asp.net application on Windows XP(SP2), Internet Explorer (V 6). SQL Server is running on the same machine. To login the user browses to http://machinename/default.aspx. Here...
2
by: adam | last post by:
Hi ASP Expert, I encounter a page reload situation in ASP. It is I need a way to differentiate whether the current page - "Application_Result.asp" got reloaded itself when user click on the...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
3
by: Dale | last post by:
I have a very simple ASP page that when I try and access it, I get the following error: The requested resource is in use. I went through the event viewer and noticed the system log is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.