root directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    root directory

    Hi
    How do I refer to the root of the IIS installation in code please?
    TIA

    --



  • Mark Rae

    #2
    Re: root directory

    <dl> wrote in message news:uZauEGVdFH A.1456@TK2MSFTN GP15.phx.gbl...
    [color=blue]
    > How do I refer to the root of the IIS installation in code please?[/color]

    Request.ServerV ariables["APPL_PHYSICAL_ PATH"]


    Comment

    • Guest's Avatar

      #3
      Re: root directory

      Thanks, this is close. I will use it.
      Can we get the FQDN or the hostname/computername of the IIS server, please?!
      TIA
      "Mark Rae" <mark@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
      news:%239SMP$Vd FHA.3396@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > <dl> wrote in message news:uZauEGVdFH A.1456@TK2MSFTN GP15.phx.gbl...
      >[color=green]
      > > How do I refer to the root of the IIS installation in code please?[/color]
      >
      > Request.ServerV ariables["APPL_PHYSICAL_ PATH"]
      >
      >[/color]


      Comment

      • Mark Rae

        #4
        Re: root directory

        <dl> wrote in message news:uCe4Q9WdFH A.3492@TK2MSFTN GP14.phx.gbl...
        [color=blue]
        > Can we get the FQDN or the hostname/computername of the IIS server,
        > please?![/color]

        System.Environm ent.MachineName


        Comment

        • Juan T. Llibre

          #5
          Re: root directory

          That's not a fully qualified domain name.
          It's only the machine name, which may be different.

          Request.ServerV ariables("HTTP_ HOST")
          returns the complete domain name.



          Juan T. Llibre
          ASP.NET MVP

          Foros de ASP.NET en Español
          Ven, y hablemos de ASP.NET...
          =============== =======

          "Mark Rae" <mark@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
          news:uhpSLVYdFH A.584@TK2MSFTNG P15.phx.gbl...[color=blue]
          > <dl> wrote in message news:uCe4Q9WdFH A.3492@TK2MSFTN GP14.phx.gbl...
          >[color=green]
          >> Can we get the FQDN or the hostname/computername of the IIS server, please?![/color]
          >
          > System.Environm ent.MachineName
          >[/color]


          Comment

          • Mark Rae

            #6
            Re: root directory

            "Juan T. Llibre" <nomailreplies@ nowhere.com> wrote in message
            news:eFotRzYdFH A.3328@TK2MSFTN GP09.phx.gbl...
            [color=blue]
            > That's not a fully qualified domain name.
            > It's only the machine name, which may be different.[/color]

            You're right - I didn't read the reply properly - apologies.
            [color=blue]
            > Request.ServerV ariables("HTTP_ HOST")
            > returns the complete domain name.[/color]

            Yes indeed.


            Comment

            • Guest's Avatar

              #7
              Re: root directory

              Thanks guys. Is there a place I can refer to for a list of such
              "variables" ?

              "Mark Rae" <mark@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
              news:Oa$%23mHZd FHA.1288@tk2msf tngp13.phx.gbl. ..[color=blue]
              > "Juan T. Llibre" <nomailreplies@ nowhere.com> wrote in message
              > news:eFotRzYdFH A.3328@TK2MSFTN GP09.phx.gbl...
              >[color=green]
              > > That's not a fully qualified domain name.
              > > It's only the machine name, which may be different.[/color]
              >
              > You're right - I didn't read the reply properly - apologies.
              >[color=green]
              > > Request.ServerV ariables("HTTP_ HOST")
              > > returns the complete domain name.[/color]
              >
              > Yes indeed.
              >
              >[/color]


              Comment

              • Juan T. Llibre

                #8
                Re: root directory

                re:[color=blue]
                > Is there a place I can refer to for a list of such "variables" ?[/color]

                I use this handy dynamic page to list them :

                servervars.aspx :
                -----------------
                <%@ Page Language="vb" %>
                <%@ Import Namespace = "System.Web " %>
                <script runat="server">

                Public Sub Page_Load(Sende r As System.Object, E As System.EventArg s)

                'Server Variables
                Dim vars As NameValueCollec tion = Request.ServerV ariables

                If Not IsPostBack Then
                Names.DataSourc e=vars
                Names.DataBind( )
                Else
                ValuesHead.Text = "Values: "
                If vars.Get(Names. SelectedItem.Te xt).ToString() = Nothing Then
                Values.Text = "null"
                Else
                Values.Text = vars.Get(Names. SelectedItem.Te xt).ToString()
                End If
                End If
                End Sub

                </script>
                <html>
                <head>
                </head>
                <body>
                <form id="Form1" runat="server">
                <h3>Retrievin g Server Variables
                </h3>
                <p>
                Retrieve:
                <asp:DropDownLi st id="Names" runat="server" AutoPostBack="t rue"></asp:DropDownLis t>
                <br />
                <asp:Label id="ValuesHead " runat="server"> </asp:Label>
                <br />
                <b><asp:Label id="Values" runat="server" backcolor="Beig e" width="500"></asp:Label></b>
                </p>

                </form>
                </body>
                </html>
                -----------

                That way, I have all the variables, and their names, easily available.

                Remember that the general format for retrieving server variables is :

                Request.ServerV ariables("VARIA BLE_NAME")

                Also, there's quite a few equivalents in the native .Net class system.web,
                by retrieving the properties for System.Web.Http Request .

                See :


                If you prefer using a .net native method, that's the way to go.



                Juan T. Llibre
                ASP.NET MVP

                Foros de ASP.NET en Español
                Ven, y hablemos de ASP.NET...
                =============== =======

                <dl> wrote in message news:OVMX1PZdFH A.3808@TK2MSFTN GP14.phx.gbl...[color=blue]
                > Thanks guys. Is there a place I can refer to for a list of such
                > "variables" ?
                >
                > "Mark Rae" <mark@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
                > news:Oa$%23mHZd FHA.1288@tk2msf tngp13.phx.gbl. ..[color=green]
                >> "Juan T. Llibre" <nomailreplies@ nowhere.com> wrote in message
                >> news:eFotRzYdFH A.3328@TK2MSFTN GP09.phx.gbl...
                >>[color=darkred]
                >> > That's not a fully qualified domain name.
                >> > It's only the machine name, which may be different.[/color]
                >>
                >> You're right - I didn't read the reply properly - apologies.
                >>[color=darkred]
                >> > Request.ServerV ariables("HTTP_ HOST")
                >> > returns the complete domain name.[/color]
                >>
                >> Yes indeed.
                >>
                >>[/color]
                >
                >[/color]

                Comment

                Working...