Application Address

Discussion in 'ASP .Net' started by Shimon Sim, Jan 12, 2005.

  1. Shimon Sim

    Shimon Sim Guest

    Hi
    I need to get application address that will look like this
    http://www.mysite.com
    I tried already Request.FilePaht that the documentation says that it returns
    the full path of the request including host name but on my machine for some
    reason it only returns virtual path and is equal RawUrl.

    What's wrong? How can I get host name programmatically?
    Shimon
     
    Shimon Sim, Jan 12, 2005
    #1
    1. Advertising

  2. Shimon Sim

    Curt_C [MVP] Guest

    start here maybe
    for(int i = 0;i < Request.ServerVariables.Count;i++)

    {

    Response.Write(Request.ServerVariables.ToString() + "<br>");

    }


    --
    Curt Christianson
    Site & Scripts: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Shimon Sim" <> wrote in message
    news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it
    > returns the full path of the request including host name but on my machine
    > for some reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
    >
     
    Curt_C [MVP], Jan 12, 2005
    #2
    1. Advertising

  3. Shimon Sim

    Jakub Guest

    Try Request.Url


    "Shimon Sim" <> pí¹e v diskusním pøíspìvku
    news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it
    > returns the full path of the request including host name but on my machine
    > for some reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
    >
     
    Jakub, Jan 12, 2005
    #3
  4. Shimon Sim

    Curt_C [MVP] Guest

    If you are in a virtual dir it will show that, not the base URL


    --
    Curt Christianson
    Site & Scripts: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Jakub" <> wrote in message
    news:emyhIDP%...
    > Try Request.Url
    >
    >
    > "Shimon Sim" <> pí¹e v diskusním pøíspìvku
    > news:eggRj6O%...
    >> Hi
    >> I need to get application address that will look like this
    >> http://www.mysite.com
    >> I tried already Request.FilePaht that the documentation says that it
    >> returns the full path of the request including host name but on my
    >> machine for some reason it only returns virtual path and is equal RawUrl.
    >>
    >> What's wrong? How can I get host name programmatically?
    >> Shimon
    >>

    >
    >
     
    Curt_C [MVP], Jan 12, 2005
    #4
  5. Shimon Sim

    Curt_C [MVP] Guest

    Whoops... nevermind...
    Thought that was Request.Servervariables["URL"]

    --
    Curt Christianson
    Site & Scripts: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Jakub" <> wrote in message
    news:emyhIDP%...
    > Try Request.Url
    >
    >
    > "Shimon Sim" <> pí¹e v diskusním pøíspìvku
    > news:eggRj6O%...
    >> Hi
    >> I need to get application address that will look like this
    >> http://www.mysite.com
    >> I tried already Request.FilePaht that the documentation says that it
    >> returns the full path of the request including host name but on my
    >> machine for some reason it only returns virtual path and is equal RawUrl.
    >>
    >> What's wrong? How can I get host name programmatically?
    >> Shimon
    >>

    >
    >
     
    Curt_C [MVP], Jan 12, 2005
    #5
  6. <%@ Page Language="VB" %>
    <script language="VB" runat="server">
    Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
    Dim dnsname As String = Request.ServerVariables("HTTP_HOST")
    Label1.Text = dnsname
    End Sub
    </script>
    <head>
    <title>Retrieve Server DNS Name</title>
    </head>
    <html>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="Label1" Runat="server" Text="Label" Width="238px" Height="19px"></asp:Label><br />
    </div>
    </form>
    </body>
    </html>


    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Shimon Sim" <> wrote in message news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it returns
    > the full path of the request including host name but on my machine for some
    > reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
     
    Juan T. Llibre, Jan 12, 2005
    #6
  7. You can also use Request.Url.Host

    <%@ Page Language="VB" %>
    <script language="VB" runat="server">
    Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
    Dim dnsname As String = Request.Url.Host
    Label1.Text = dnsname
    End Sub
    </script>
    <head>
    <title>Retrieve Server DNS Name</title>
    </head>
    <html>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="Label1" Runat="server" Text="Label" Width="238px" Height="19px"></asp:Label><br />
    </div>
    </form>
    </body>
    </html>



    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Shimon Sim" <> wrote in message news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it returns
    > the full path of the request including host name but on my machine for some
    > reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
    >
    >
     
    Juan T. Llibre, Jan 12, 2005
    #7
  8. Shimon Sim

    Shimon Sim Guest

    thanks. Request.Url has plenty info and works as expected.
    What's wrong with RawUrl??
    Shimon.
    "Jakub" <> wrote in message
    news:emyhIDP%...
    > Try Request.Url
    >
    >
    > "Shimon Sim" <> pí¹e v diskusním pøíspìvku
    > news:eggRj6O%...
    >> Hi
    >> I need to get application address that will look like this
    >> http://www.mysite.com
    >> I tried already Request.FilePaht that the documentation says that it
    >> returns the full path of the request including host name but on my
    >> machine for some reason it only returns virtual path and is equal RawUrl.
    >>
    >> What's wrong? How can I get host name programmatically?
    >> Shimon
    >>

    >
    >
     
    Shimon Sim, Jan 12, 2005
    #8
  9. Shimon Sim

    Shimon Sim Guest

    Thanks Juan
    Shimon.
    "Juan T. Llibre" <> wrote in message news:uO2ACTP%...
    You can also use Request.Url.Host

    <%@ Page Language="VB" %>
    <script language="VB" runat="server">
    Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
    Dim dnsname As String = Request.Url.Host
    Label1.Text = dnsname
    End Sub
    </script>
    <head>
    <title>Retrieve Server DNS Name</title>
    </head>
    <html>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="Label1" Runat="server" Text="Label" Width="238px" Height="19px"></asp:Label><br />
    </div>
    </form>
    </body>
    </html>



    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Shimon Sim" <> wrote in message news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it returns
    > the full path of the request including host name but on my machine for some
    > reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
    >
    >
     
    Shimon Sim, Jan 12, 2005
    #9
  10. Shimon Sim

    Karl Seguin Guest

    /me raises an eyebrow

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Juan T. Llibre" <> wrote in message news:uO2ACTP%...
    You can also use Request.Url.Host

    <%@ Page Language="VB" %>
    <script language="VB" runat="server">
    Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
    Dim dnsname As String = Request.Url.Host
    Label1.Text = dnsname
    End Sub
    </script>
    <head>
    <title>Retrieve Server DNS Name</title>
    </head>
    <html>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="Label1" Runat="server" Text="Label" Width="238px" Height="19px"></asp:Label><br />
    </div>
    </form>
    </body>
    </html>



    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Shimon Sim" <> wrote in message news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it returns
    > the full path of the request including host name but on my machine for some
    > reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
    >
    >
     
    Karl Seguin, Jan 13, 2005
    #10
  11. I'm a quick study, Karl.

    ;-)

    Actually, I don't know why that
    didn't work when I first tested it.

    The first time I ran it, it only returned the IP address.

    When I ran it again, after you objected, it returned
    what it's supposed to return: the hostname.

    I attribute it to evil internet pixies. :)



    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:%23u5W0ZQ%...
    /me raises an eyebrow

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Juan T. Llibre" <> wrote in message
    news:uO2ACTP%...
    You can also use Request.Url.Host

    <%@ Page Language="VB" %>
    <script language="VB" runat="server">
    Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
    Dim dnsname As String = Request.Url.Host
    Label1.Text = dnsname
    End Sub
    </script>
    <head>
    <title>Retrieve Server DNS Name</title>
    </head>
    <html>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="Label1" Runat="server" Text="Label" Width="238px"
    Height="19px"></asp:Label><br />
    </div>
    </form>
    </body>
    </html>



    Juan T. Llibre
    ASP.NET MVP
    ===========
    "Shimon Sim" <> wrote in message
    news:eggRj6O%...
    > Hi
    > I need to get application address that will look like this
    > http://www.mysite.com
    > I tried already Request.FilePaht that the documentation says that it

    returns
    > the full path of the request including host name but on my machine for

    some
    > reason it only returns virtual path and is equal RawUrl.
    >
    > What's wrong? How can I get host name programmatically?
    > Shimon
    >
    >
     
    Juan T. Llibre, Jan 13, 2005
    #11
  12. Shimon Sim

    Karl Seguin Guest

    Funny, we have leprechauns in canada ;)

    Cheers,
    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Juan T. Llibre" <> wrote in message
    news:%23F24heQ%...
    > I'm a quick study, Karl.
    >
    > ;-)
    >
    > Actually, I don't know why that
    > didn't work when I first tested it.
    >
    > The first time I ran it, it only returned the IP address.
    >
    > When I ran it again, after you objected, it returned
    > what it's supposed to return: the hostname.
    >
    > I attribute it to evil internet pixies. :)
    >
    >
    >
    > Juan T. Llibre
    > ASP.NET MVP
    > ===========
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > wrote in message news:%23u5W0ZQ%...
    > /me raises an eyebrow
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "Juan T. Llibre" <> wrote in message
    > news:uO2ACTP%...
    > You can also use Request.Url.Host
    >
    > <%@ Page Language="VB" %>
    > <script language="VB" runat="server">
    > Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
    > Dim dnsname As String = Request.Url.Host
    > Label1.Text = dnsname
    > End Sub
    > </script>
    > <head>
    > <title>Retrieve Server DNS Name</title>
    > </head>
    > <html>
    > <body>
    > <form id="form1" runat="server">
    > <div>
    > <asp:Label ID="Label1" Runat="server" Text="Label" Width="238px"
    > Height="19px"></asp:Label><br />
    > </div>
    > </form>
    > </body>
    > </html>
    >
    >
    >
    > Juan T. Llibre
    > ASP.NET MVP
    > ===========
    > "Shimon Sim" <> wrote in message
    > news:eggRj6O%...
    > > Hi
    > > I need to get application address that will look like this
    > > http://www.mysite.com
    > > I tried already Request.FilePaht that the documentation says that it

    > returns
    > > the full path of the request including host name but on my machine for

    > some
    > > reason it only returns virtual path and is equal RawUrl.
    > >
    > > What's wrong? How can I get host name programmatically?
    > > Shimon
    > >
    > >

    >
    >
     
    Karl Seguin, Jan 13, 2005
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. avnrao
    Replies:
    1
    Views:
    7,232
    avnrao
    May 4, 2004
  2. Patrice
    Replies:
    0
    Views:
    890
    Patrice
    May 4, 2004
  3. Raterus
    Replies:
    0
    Views:
    439
    Raterus
    Jun 2, 2004
  4. Alex Stevens
    Replies:
    0
    Views:
    781
    Alex Stevens
    Aug 10, 2004
  5. =?Utf-8?B?QW5nZWw=?=

    Pass a Web Address and return a File System Address

    =?Utf-8?B?QW5nZWw=?=, Sep 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    541
    =?Utf-8?B?U3RldmUgQy4gT3Jy?=
    Sep 21, 2005
Loading...

Share This Page