Saturday, March 31, 2012

What is my website name

I am looking for a property in the page object that would return something l
ike
"http://localhost:1530/myapp"
What property should I look for?
Arne Garvander
Certified G
Professional Data DudeOn Aug 2, 11:12 pm, Arne <A...@.discussions.microsoft.com> 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
"Arne" <Arne@.discussions.microsoft.com> 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
page.request.url works better
--
Arne Garvander
Certified G
Professional Data Dude
"Mark Rae [MVP]" wrote:

> "Arne" <Arne@.discussions.microsoft.com> wrote in message
> news:94C9C2BF-959D-4E36-8555-FC3D1259AA22@.microsoft.com...
>
> Request.ServerVariables["HTTP_HOST"]
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
No they don't work so well
The page.request.uri works better.
--
Arne Garvander
Certified G
Professional Data Dude
"Alexey Smirnov" wrote:

> On Aug 2, 11:12 pm, Arne <A...@.discussions.microsoft.com> wrote:
> Arne, you can use the Request.ServerVariables() method
> http://www.4guysfromrolla.com/webtech/092298-3.shtml
>
"Arne" <Arne@.discussions.microsoft.com> 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
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 r
oot 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" <Arne@.discussions.microsoft.com> wrote in message news:94C9C2BF-959D-4E36-8555-FC3D1
259AA22@.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 G
> Professional Data Dude
"Juan T. Llibre" <nomailreplies@.nowhere.com> 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
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 & Reque
st.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]" <mark@.markNOSPAMrae.net> wrote in message news:%23G2XEiZ1HHA.4428@.TK2MSFTNGP03.
phx.gbl...
> "Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message news:OYTlMAX
1HHA.4496@.TK2MSFTNGP02.phx.gbl...
>
> What if it's https...?
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
"Juan T. Llibre" <nomailreplies@.nowhere.com> 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

0 comments:

Post a Comment