Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   What is my website name (http://www.velocityreviews.com/forums/t526581-what-is-my-website-name.html)

=?Utf-8?B?QXJuZQ==?= 08-02-2007 09:12 PM

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

Alexey Smirnov 08-02-2007 09:27 PM

Re: What is my website name
 
On 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


Mark Rae [MVP] 08-02-2007 09:29 PM

Re: What is my website name
 
"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


=?Utf-8?B?QXJuZQ==?= 08-02-2007 09:46 PM

Re: What is my website name
 
page.request.url works better
--
Arne Garvander
Certified Geek
Professional Data Dude


"Mark Rae [MVP]" wrote:

> "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
>
>


=?Utf-8?B?QXJuZQ==?= 08-02-2007 09:46 PM

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 <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
>
>


Mark Rae [MVP] 08-02-2007 10:09 PM

Re: What is my website name
 
"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


Juan T. Llibre 08-03-2007 01:45 AM

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 espaņol : http://asp.net.do/foros/
======================================
"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?
>
> --
> Arne Garvander
> Certified Geek
> Professional Data Dude




Mark Rae [MVP] 08-03-2007 06:35 AM

Re: What is my website name
 
"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


Juan T. Llibre 08-03-2007 12:07 PM

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 espaņol : 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: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




Mark Rae [MVP] 08-03-2007 12:17 PM

Re: What is my website name
 
"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



All times are GMT. The time now is 12:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.