469,621 Members | 1,678 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

What is my website name

I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude
Aug 2 '07 #1
15 1876
On Aug 2, 11:12 pm, Arne <A...@discussions.microsoft.comwrote:
I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?
Arne, you can use the Request.ServerVariables() method

http://www.4guysfromrolla.com/webtech/092298-3.shtml

Aug 2 '07 #2
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
>I am looking for a property in the page object that would return something
like
"http://localhost:1530/myapp"
What property should I look for?
Request.ServerVariables["HTTP_HOST"]
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '07 #3
page.request.url works better
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
I am looking for a property in the page object that would return something
like
"http://localhost:1530/myapp"
What property should I look for?

Request.ServerVariables["HTTP_HOST"]
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '07 #4
No they don't work so well
The page.request.uri works better.
--
Arne Garvander
Certified Geek
Professional Data Dude
"Alexey Smirnov" wrote:
On Aug 2, 11:12 pm, Arne <A...@discussions.microsoft.comwrote:
I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

Arne, you can use the Request.ServerVariables() method

http://www.4guysfromrolla.com/webtech/092298-3.shtml

Aug 2 '07 #5
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
page.request.url works better
How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 2 '07 #6
Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpathandport as string = "The full URL and port for the application root is : " & "http://" & fullappname & ":" &
port & Request.ApplicationPath & "/"

See a working example at : http://asp.net.do/test/apppath.aspx
( the last line returns the info you want ... )


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/
======================================
"Arne" <Ar**@discussions.microsoft.comwrote in message news:94**********************************@microsof t.com...
>I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude

Aug 3 '07 #7
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OY**************@TK2MSFTNGP02.phx.gbl...
Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpathandport as string = "The full URL and port for the application
root is : " & "http://" & fullappname & ":" & port &
Request.ApplicationPath & "/"
What if it's https...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #8
I don't have a server certificate handy to test this, but this should cover that :

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim MyUrl As Uri = Request.Url
Dim fullappnameProtocolAndPort As String = "The full URL, protocol and port for the application root is : " _
& Server.HtmlEncode(MyUrl.Scheme) & "://" & fullappname & ":" & port & Request.ApplicationPath & "/"


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/
======================================
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OY**************@TK2MSFTNGP02.phx.gbl...
>Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpathandport as string = "The full URL and port for the application root is : " & "http://" & fullappname &
":" & port & Request.ApplicationPath & "/"

What if it's https...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #9
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OZ**************@TK2MSFTNGP03.phx.gbl...
>I don't have a server certificate handy to test this, but this should cover
that :
I normally use something like this:

string strWebRoot = (Request.ServerVariables["HTTPS"] == "off" ? "http://" :
"https://") + Request.ServerVariables["SERVER_NAME"];
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #10
You get portnumber, protocol
page.Request.Url.Scheme + "://" + page.Request.Url.Authority + _
"/" + page.Request.Url.Segments(1)
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
page.request.url works better

How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #11
Request.ServerVariables["SERVER_NAME"]; and Request.Url.Host return the same object, right ?

You're missing the application's name and the port, per the OP's request, though.

There's many ways to skin a cat.

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim prot as object = IIf(Request.ServerVariables("HTTPS")="on", "https://", "http://")
Dim path as String = prot.ToString() & fullappname & ":" & port & Request.ApplicationPath

....will also do the job.

:-)


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/
======================================
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message news:e7**************@TK2MSFTNGP05.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OZ**************@TK2MSFTNGP03.phx.gbl...
>>I don't have a server certificate handy to test this, but this should cover that :
I normally use something like this:
string strWebRoot = (Request.ServerVariables["HTTPS"] == "off" ? "http://" : "https://") +
Request.ServerVariables["SERVER_NAME"];
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #12
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eW**************@TK2MSFTNGP02.phx.gbl...
Request.ServerVariables["SERVER_NAME"]; and Request.Url.Host return the
same object, right ?
Yes - AFAIK, Request.Url is just a wrapper around Request.ServerVariables...
You're missing the application's name and the port, per the OP's request,
though.
Probably... :-)
There's many ways to skin a cat.

Dim fullappname as string = Request.Url.Host
Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim prot as object = IIf(Request.ServerVariables("HTTPS")="on",
"https://", "http://")
Dim path as String = prot.ToString() & fullappname & ":" & port &
Request.ApplicationPath

...will also do the job.
Indeed.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 3 '07 #13
That's very compact, Arne.

That only leaves the port to be added :

Dim port as string = Request.ServerVariables("SERVER_PORT")
Dim fullpath as string = page.Request.Url.Scheme + "://" + page.Request.Url.Authority + ":" + port + "/" +
page.Request.Url.Segments(1)

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/
======================================
"Arne" <Ar**@discussions.microsoft.comwrote in message news:2D**********************************@microsof t.com...
You get portnumber, protocol
page.Request.Url.Scheme + "://" + page.Request.Url.Authority + _
"/" + page.Request.Url.Segments(1)
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
>"Arne" <Ar**@discussions.microsoft.comwrote in message
news:6E**********************************@microso ft.com...
page.request.url works better

How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Aug 3 '07 #14
page.request.uri

--
<a href="http://1pakistangifts.com">Send Gifts to Pakisan at #Pakistan Gifts
Store</a| <a href="http://dotspecialists.com">Leading Software offshoring
and outsourcing service provider</a| <a
href="http://websitedesignersrus.com">Professional Websites at affordable
prices</a>
"Arne" <Ar**@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
>I am looking for a property in the page object that would return something
like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude


Aug 6 '07 #15
re:
!page.request.uri

That does *not* produce what the OP requested.

The OP wants to :

1. include the port number
2. *not* include the page's name

Please review this thread. The answer has already been provided in it.


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/
======================================
"Enigma Boy" <en*******@pp.newsgroups.userwrote in message news:CT*****************@fe103.usenetserver.com...
page.request.uri

--
<a href="http://1pakistangifts.com">Send Gifts to Pakisan at #Pakistan Gifts Store</a| <a
href="http://dotspecialists.com">Leading Software offshoring and outsourcing service provider</a| <a
href="http://websitedesignersrus.com">Professional Websites at affordable prices</a>
"Arne" <Ar**@discussions.microsoft.comwrote in message news:94**********************************@microsof t.com...
>>I am looking for a property in the page object that would return something like
"http://localhost:1530/myapp"
What property should I look for?

--
Arne Garvander
Certified Geek
Professional Data Dude



Aug 6 '07 #16

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by PassingBy | last post: by
3 posts views Thread by Wayne Gibson | last post: by
11 posts views Thread by Paul Brady | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.