root directory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

--
 
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 said:
How do I refer to the root of the IIS installation in code please?

Request.ServerVariables["APPL_PHYSICAL_PATH"]
 
That's not a fully qualified domain name.
It's only the machine name, which may be different.

Request.ServerVariables("HTTP_HOST")
returns the complete domain name.



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
That's not a fully qualified domain name.
It's only the machine name, which may be different.

You're right - I didn't read the reply properly - apologies.
Request.ServerVariables("HTTP_HOST")
returns the complete domain name.

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

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(Sender As System.Object, E As System.EventArgs)

'Server Variables
Dim vars As NameValueCollection = Request.ServerVariables

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

</script>
<html>
<head>
</head>
<body>
<form id="Form1" runat="server">
<h3>Retrieving Server Variables
</h3>
<p>
Retrieve:
<asp:DropDownList id="Names" runat="server" AutoPostBack="true"></asp:DropDownList>
<br />
<asp:Label id="ValuesHead" runat="server"></asp:Label>
<br />
<b><asp:Label id="Values" runat="server" backcolor="Beige" 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.ServerVariables("VARIABLE_NAME")

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

See :
http://www.csharpfriends.com/quicks...d50a3a&namespace=System.Web&class=HttpRequest

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



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top