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
Date:Thu, 2 Aug 2007 14:12:02 -0700
Author:
|
Re: What is my website name
On Aug 2, 11:12 pm, Arne wrote:
> 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
Date:Thu, 02 Aug 2007 14:27:29 -0700
Author:
|
Re: What is my website name
"Arne" wrote in message
news:94C9C2BF-959D-4E36-8555-FC3D1259AA22@microsoft.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
Date:Thu, 2 Aug 2007 22:29:35 +0100
Author:
|
Re: What is my website name
page.request.url works better
--
Arne Garvander
Certified Geek
Professional Data Dude
"Mark Rae [MVP]" wrote:
> "Arne" wrote in message
> news:94C9C2BF-959D-4E36-8555-FC3D1259AA22@microsoft.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
>
>
Date:Thu, 2 Aug 2007 14:46:01 -0700
Author:
|
Re: What is my website name
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 wrote:
> > 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
>
>
Date:Thu, 2 Aug 2007 14:46:03 -0700
Author:
|
Re: What is my website name
"Arne" wrote in message
news:6EAB5661-612F-49D6-BEBA-AE092365BD14@microsoft.com...
> page.request.url works better
How exactly does it "work better"...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Thu, 2 Aug 2007 23:09:09 +0100
Author:
|
Re: What is my website name
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 espaol : http://asp.net.do/foros/
======================================
"Arne" wrote in message news:94C9C2BF-959D-4E36-8555-FC3D1259AA22@microsoft.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
Date:Thu, 2 Aug 2007 21:45:54 -0400
Author:
|
Re: What is my website name
"Juan T. Llibre" wrote in message
news:OYTlMAX1HHA.4496@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
Date:Fri, 3 Aug 2007 07:35:45 +0100
Author:
|
Re: What is my website name
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 espaol : http://asp.net.do/foros/
======================================
"Mark Rae [MVP]" wrote in message news:%23G2XEiZ1HHA.4428@TK2MSFTNGP03.phx.gbl...
> "Juan T. Llibre" wrote in message news:OYTlMAX1HHA.4496@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
Date:Fri, 3 Aug 2007 08:07:24 -0400
Author:
|
Re: What is my website name
"Juan T. Llibre" wrote in message
news:OZX4ebc1HHA.4428@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
Date:Fri, 3 Aug 2007 13:17:29 +0100
Author:
|
Re: What is my website name
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" wrote in message
> news:6EAB5661-612F-49D6-BEBA-AE092365BD14@microsoft.com...
>
> > page.request.url works better
>
> How exactly does it "work better"...?
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>
Date:Fri, 3 Aug 2007 06:04:01 -0700
Author:
|
Re: What is my website name
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 espaol : http://asp.net.do/foros/
======================================
"Mark Rae [MVP]" wrote in message news:e7vbBhc1HHA.5796@TK2MSFTNGP05.phx.gbl...
> "Juan T. Llibre" wrote in message news:OZX4ebc1HHA.4428@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
Date:Fri, 3 Aug 2007 09:13:30 -0400
Author:
|
Re: What is my website name
"Juan T. Llibre" wrote in message
news:eW84aAd1HHA.1164@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
Date:Fri, 3 Aug 2007 14:28:19 +0100
Author:
|
Re: What is my website name
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 espaol : http://asp.net.do/foros/
======================================
"Arne" wrote in message news:2D26E478-EB26-43E6-AA31-D7DD0118E099@microsoft.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" wrote in message
>> news:6EAB5661-612F-49D6-BEBA-AE092365BD14@microsoft.com...
>>
>> > page.request.url works better
>>
>> How exactly does it "work better"...?
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net
>>
>>
Date:Fri, 3 Aug 2007 09:56:25 -0400
Author:
|
Re: What is my website name
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" wrote in message
news:94C9C2BF-959D-4E36-8555-FC3D1259AA22@microsoft.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
>
Date:Mon, 6 Aug 2007 12:14:45 +0500
Author:
|
Re: What is my website name
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 espaol : http://asp.net.do/foros/
======================================
"Enigma Boy" wrote in message news:CTzti.3393$9W6.2439@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" wrote in message news:94C9C2BF-959D-4E36-8555-FC3D1259AA22@microsoft.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
>>
>
>
>
Date:Mon, 6 Aug 2007 06:57:43 -0400
Author:
|