473,401 Members | 2,139 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,401 software developers and data experts.

Retrieving IIS Web Site Property Value during Application_Start in ASP.NET Web app.

How would it be possible for an ASP.NET Web application, in it's
Application_Start event procedure, to programmatically determine the Web
site (in IIS) that the Web app is running under/for.

Say for example, that I have a Web site defined in IIS, with the
"Application name" property set to the value "MyWebApp". How could I get
the value "MyWebApp" into a string variable in Application_Start of the
ASP.NET Web application?

Please note that I'd like to get this value directly from IIS, and not have
to manually duplicate it in Web.config.

I'm currently using ASP.NET 3.5 with IIS 5.1 and 6, but will soon be
migratign everything to IIS 7.

Thanks.

Jun 27 '08 #1
3 1803
On Apr 18, 3:36*pm, "Jordan S." <A...@B.comwrote:
How would it be possible for an ASP.NET Web application, in it's
Application_Start event procedure, to programmatically determine the Web
site (in IIS) that the Web app is running under/for.

Say for example, that I have a Web site defined in IIS, with the
"Application name" property set to the value "MyWebApp". *How could I get
the value "MyWebApp" into a string variable in Application_Start of the
ASP.NET Web application?

Please note that I'd like to get this value directly from IIS, and not have
to manually duplicate it in Web.config.

I'm currently using ASP.NET 3.5 with IIS 5.1 and 6, but will soon be
migratign everything to IIS 7.

Thanks.

That value is stored in the Metabase. You should be able to use ADSI
or WMI to retrieve that value from the IIS Metabase.

However, IIS7 does not install with metabase support because it is
legacy. Instead, there is a new configuration store and schema that
maps onto ASP.Net .config files. What is used as identifier for a
website changes as well (though legacy interop layer tries to hide
some details).

In short, what are you trying to do?
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
Jun 27 '08 #2
request.serverVariables("SERVER_SOFTWARE")

"David Wang" <w3*****@gmail.comwrote in message
news:23**********************************@v23g2000 pro.googlegroups.com...
On Apr 18, 3:36 pm, "Jordan S." <A...@B.comwrote:
How would it be possible for an ASP.NET Web application, in it's
Application_Start event procedure, to programmatically determine the Web
site (in IIS) that the Web app is running under/for.

Say for example, that I have a Web site defined in IIS, with the
"Application name" property set to the value "MyWebApp". How could I get
the value "MyWebApp" into a string variable in Application_Start of the
ASP.NET Web application?

Please note that I'd like to get this value directly from IIS, and not
have
to manually duplicate it in Web.config.

I'm currently using ASP.NET 3.5 with IIS 5.1 and 6, but will soon be
migratign everything to IIS 7.

Thanks.

That value is stored in the Metabase. You should be able to use ADSI
or WMI to retrieve that value from the IIS Metabase.

However, IIS7 does not install with metabase support because it is
legacy. Instead, there is a new configuration store and schema that
maps onto ASP.Net .config files. What is used as identifier for a
website changes as well (though legacy interop layer tries to hide
some details).

In short, what are you trying to do?
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//

Jun 27 '08 #3
re:
!request.serverVariables("SERVER_SOFTWARE")

Sorry. That returns the IIS version.

The correct answer, in any ASP.NET page, is...

Dim appname as string = Request.ApplicationPath.Substring(1, Request.ApplicationPath.Length-1)
apppath.text = "The application's name is : " & appname

This code assumes you have a texbox named apppath.

You can also use, in global.asax's Application_Start :

Dim MyArray() As String = Split(AppDomain.CurrentDomain.DynamicDirectory, "\")
Application("APP_VIRTUAL_DIR") = (MyArray(6).ToString())

....and, in the page :

Dim AppVirtualDir as string = Application("APP_VIRTUAL_DIR")
apppath.text = AppVirtualDir

This code assumes you have a texbox named apppath.
You can use the AppVirtualDir variable as you see fit.


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/
======================================
"ThatsIT.net.au" <me@workwrote in message news:2C**********************************@microsof t.com...
request.serverVariables("SERVER_SOFTWARE")

"David Wang" <w3*****@gmail.comwrote in message
news:23**********************************@v23g2000 pro.googlegroups.com...
On Apr 18, 3:36 pm, "Jordan S." <A...@B.comwrote:
>How would it be possible for an ASP.NET Web application, in it's
Application_Start event procedure, to programmatically determine the Web
site (in IIS) that the Web app is running under/for.

Say for example, that I have a Web site defined in IIS, with the
"Application name" property set to the value "MyWebApp". How could I get
the value "MyWebApp" into a string variable in Application_Start of the
ASP.NET Web application?

Please note that I'd like to get this value directly from IIS, and not have
to manually duplicate it in Web.config.

I'm currently using ASP.NET 3.5 with IIS 5.1 and 6, but will soon be
migratign everything to IIS 7.

Thanks.


That value is stored in the Metabase. You should be able to use ADSI
or WMI to retrieve that value from the IIS Metabase.

However, IIS7 does not install with metabase support because it is
legacy. Instead, there is a new configuration store and schema that
maps onto ASP.Net .config files. What is used as identifier for a
website changes as well (though legacy interop layer tries to hide
some details).

In short, what are you trying to do?
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//

Jun 27 '08 #4

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

Similar topics

3
by: Nathan Phelps | last post by:
I realize that I could find my virtual directory using some of the methods in the HttpRequest object, but since the HttpRequest object is not in context during the Application_Start event, I'm at a...
1
by: bill yeager | last post by:
I would like to place the currently selected date (retrieved from the database) on a calendar control which is embedded inside a datagrid. However, I can't find the ID of the control to do so....
2
by: Sakke | last post by:
Hello! We have written a GCryptoSvr.dll COM server in C++. Inside that resides WebClient COM component. WebClient CLSID is {8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that...
5
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.