473,421 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

How to get the Web Site Identification information from inside the application

I am relatively new to Web development and I have a pretty simple
question. How do I get the web site identification information (from
IIS) inside my aspx.cs? Spacifically I want the web pages name and the
port number.

Thanks.

Nov 19 '05 #1
5 5073
use

Request and Server object
"Mike" <mi***************@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I am relatively new to Web development and I have a pretty simple
question. How do I get the web site identification information (from
IIS) inside my aspx.cs? Spacifically I want the web pages name and the
port number.

Thanks.

Nov 19 '05 #2
re:
Specifically I want the web pages name and the port number.
If it's just the web page name, get it with
Request.ServerVariables["SCRIPT_NAME"];

However, I suspect that you want the domain name.
Get that with Request.ServerVariables["SERVER_NAME"]

Get the port with :
Request.ServerVariables["SERVER_PORT"]

Here's a script which shows how to get all of them :

server.aspx :
-------------
<%@ Page Language="C#" %>
<html>
<head>
<title>Server IDs</title>
</head>
<script language = "C#" runat="server">
public void Page_Load(Object sender, EventArgs e){

string pagename = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);
script.Text = pagename;

string httpport = System.IO.Path.GetFileName(Request.ServerVariables["SERVER_PORT"]);
port.Text = httpport;

string domain = System.IO.Path.GetFileName(Request.ServerVariables["SERVER_NAME"]);
domain_name.Text = domain;

}
</script>
<html>
<body>
<form id="Form1" runat="server">
<p>
<asp:Label id="script" runat="server" /></asp:label><br/>
<asp:Label id="port" runat="server" /></asp:label><br/>
<asp:Label id="domain_name" runat="server" /></asp:label><br/>
</form>
</body>
</html>
--------

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

"Mike" <mi***************@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...I am relatively new to Web development and I have a pretty simple
question. How do I get the web site identification information (from
IIS) inside my aspx.cs? Spacifically I want the web pages name and the
port number.

Thanks.

Nov 19 '05 #3
Thank you for the information.

The one thing I can't find in any of those places (I tried all the
above mentioned items) is the web site description. I actually want
the desctiption field under Web site identification on the properties
page of the web site in IIS.

I want this so that if I make 2 identical web sites for 2 different web
pages I can name them different things and name my performance counters
accordingly. The port alone won't be enough though because it is not
displayed in the folder view of IIS.

I tried Request.ServerVariables["SCRIP*T_NAME"] and it gives me he
name of the script (asmx file)
I tried Request.ServerVariables["SERVE*R_NAME"] and it gives me
127.0.0.1
Request.ServerVariables["SERVE*R_PORT"] does give me the port though,
thanks for that one.

Is there an object I can use to get the Web site description for the
web site that is running?

Thanks, Mike

Nov 19 '05 #4
re:
I tried Request.ServerVariables["SCRIP*T_NAME"]
and it gives me the name of the script (asmx file)
That's what you requested ( "the web pages name" ).

re: I tried Request.ServerVariables["SERVE*R_NAME"]
and it gives me 127.0.0.1
If you're running as localhost, of course it will give you that.
The domain name is only returned if a domain actually exists.

re:I want this so that if I make 2 identical web sites for 2 different web
pages I can name them different things and name my performance
counters accordingly.
Is there an object I can use to get the Web site description for the
web site that is running?


You might be able to use Request.ServerVariables["APPL_MD_PATH"]

That will return something like :
/LM/W3SVC/1/Root/VirtualDirectory

You can use that to assign a performance counter for that website.

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

"Mike" <mi***************@hotmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Thank you for the information.

The one thing I can't find in any of those places (I tried all the
above mentioned items) is the web site description. I actually want
the desctiption field under Web site identification on the properties
page of the web site in IIS.

I want this so that if I make 2 identical web sites for 2 different web
pages I can name them different things and name my performance counters
accordingly. The port alone won't be enough though because it is not
displayed in the folder view of IIS.

I tried Request.ServerVariables["SCRIP*T_NAME"] and it gives me he
name of the script (asmx file)
I tried Request.ServerVariables["SERVE*R_NAME"] and it gives me
127.0.0.1
Request.ServerVariables["SERVE*R_PORT"] does give me the port though,
thanks for that one.

Is there an object I can use to get the Web site description for the
web site that is running?

Thanks, Mike
Nov 19 '05 #5
That will definetly give me a unique name, I think we found that
INSTANCE_ID will as well, but I actually would like to have the exact
name in IIS, so the people that administer the websites can look at the
Instance property in perfmon or MOM and compare it directly to the IIS
list and know which web service it is whithout digging. The easier I
make there job the more of it they can do :).

I am hoping that that information is exposed to the website, but I
realize it simply may not be. If anyone knows difenitevly please let
me know.

Thanks, Mike

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brad H McCollum | last post by:
I've looked through many suggestions and partial examples all over this newsgroup and still am not coming up with anything that does specifically what I'm wanting to accomplish. I'm writing a VB...
0
by: Jim | last post by:
This si a repost, I apologize but perhaps my original inquiry got buried under all the usenet spam... I need some help getting started with a .NET web project for a commercial site. I am new to...
11
by: Soha | last post by:
i building a website in a LAN which will not be published on the internet. but the users in the LAN are accessing the web site through an ISA firewall server. i would like to ask if there is a way...
23
by: Roel Melchers | last post by:
My ACCESS-database contains all members of my association. When the members attend to a meeting I want to record their presence. When they enter they identify themselves by putting their finger...
22
by: Thom Little | last post by:
Are the following values available at execution time of a windows application ... - Date the module (assembly) was compiled. - User Name specified during installation. - Organization Name...
5
by: Paps | last post by:
I build a class for implementing site access statistics but I cannot track for html pages, how can do this ? thanks Paps
2
by: suresh | last post by:
Hello to you all In my .Net application, I want to import document images (Tiff images), having same format, in a batch, For e.g. I have a document folder containing mixed images like...
1
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
6
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.