473,799 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving The Application Name Programatically

Hi,

During loading of the Global.asax, I need to get back the "applicatio n name"
that is configured in IIS. I have scoured the Http classes but there does
not seem to be any way to get to it. I know in IIS 6.0, I could retrieve it
through metabas.xml but I need this solution to work on Windows 2000, IIS
5.0 as well.

Many Thanks in advance for your help

Mike
Nov 18 '05 #1
3 3479
Mike P wrote:
Hi,

During loading of the Global.asax, I need to get back the
"applicatio n name" that is configured in IIS. I have scoured the Http
classes but there does not seem to be any way to get to it. I know in
IIS 6.0, I could retrieve it through metabas.xml but I need this
solution to work on Windows 2000, IIS
5.0 as well.


Mike,
Take a look a the Virtual Directory's AppFriendlyName property.

The following is how I created an IIS 5.x Virtual directory back in classic ASP
using vbscript:
' Create a new IIS Virtual Directory which points to the newly created Physical directory
Set oIIS = GetObject("IIS://" & sWebServerName & "/W3SVC/1/root")

' Note: the virtual directory that this ASP is ran from must have "Out-Process" un-checked,
' and "NT challenge/repsponse" must be checked, and "Anon" must be un-checked.
' Or else you will get a permission error on this line.
Set oVirtualDir = oIIS.Create("II sWebVirtualDir" , sWebVirtualDire ctoryName)
oVirtualDir.Pat h = sWebPath
oVirtualDir.Acc essRead = True
oVirtualDir.Acc essWrite = False
oVirtualDir.Acc essExecute = False
oVirtualDir.Aut hAnonymous = False
oVirtualDir.Aut hBasic = True
oVirtualDir.Aut hNTLM = True
oVirtualDir.Con tentIndexed = False
oVirtualDir.Ena bleDirBrowsing = False
oVirtualDir.App Isolated = False
If InStr(1, oVirtualDir.Def aultDoc, "Default.as p") = 0 Then
oVirtualDir.Def aultDoc = "Default.as p, " & oVirtualDir.Def aultDoc
End If
Call oVirtualDir.App Create(True)
oVirtualDir.App FriendlyName = sWebVirtualDire ctoryName
Call oVirtualDir.Set Info()
Set oVirtualDir = Nothing
Set oIIS = Nothing

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com
Nov 18 '05 #2
Carl,
Are you using WMI to do this? I can find no other reference for doing this
than WMI.

Thx

Mike
"Carl Prothman [MVP]" <ca****@spamcop .net> wrote in message
news:O2******** ******@TK2MSFTN GP12.phx.gbl...
Mike P wrote:
Hi,

During loading of the Global.asax, I need to get back the
"applicatio n name" that is configured in IIS. I have scoured the Http
classes but there does not seem to be any way to get to it. I know in
IIS 6.0, I could retrieve it through metabas.xml but I need this
solution to work on Windows 2000, IIS
5.0 as well.

Mike,
Take a look a the Virtual Directory's AppFriendlyName property.

The following is how I created an IIS 5.x Virtual directory back in

classic ASP using vbscript:
' Create a new IIS Virtual Directory which points to the newly created Physical directory Set oIIS = GetObject("IIS://" & sWebServerName & "/W3SVC/1/root")

' Note: the virtual directory that this ASP is ran from must have "Out-Process" un-checked, ' and "NT challenge/repsponse" must be checked, and "Anon" must be un-checked. ' Or else you will get a permission error on this line.
Set oVirtualDir = oIIS.Create("II sWebVirtualDir" , sWebVirtualDire ctoryName) oVirtualDir.Pat h = sWebPath
oVirtualDir.Acc essRead = True
oVirtualDir.Acc essWrite = False
oVirtualDir.Acc essExecute = False
oVirtualDir.Aut hAnonymous = False
oVirtualDir.Aut hBasic = True
oVirtualDir.Aut hNTLM = True
oVirtualDir.Con tentIndexed = False
oVirtualDir.Ena bleDirBrowsing = False
oVirtualDir.App Isolated = False
If InStr(1, oVirtualDir.Def aultDoc, "Default.as p") = 0 Then
oVirtualDir.Def aultDoc = "Default.as p, " & oVirtualDir.Def aultDoc
End If
Call oVirtualDir.App Create(True)
oVirtualDir.App FriendlyName = sWebVirtualDire ctoryName
Call oVirtualDir.Set Info()
Set oVirtualDir = Nothing
Set oIIS = Nothing

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com

Nov 18 '05 #3
Mike P wrote:
Are you using WMI to do this? I can find no other reference for doing
this than WMI.


No, I believe the code is using Active Directory Service Interfaces (ADSI)
http://msdn.microsoft.com/library/en...chitecture.asp

BTW here is some VB.NET code which will get the friendly name for you.

Dim sWebServerName As String = "carl20"
Dim sWebVirtualName As String = "temp1"
Dim sWebVirtualFrie ndlyName As String = ""

' Create a new IIS Virtual Directory which points to the newly created Physical directory
Dim oVirtualDir As Object = GetObject("IIS://" & sWebServerName & "/W3SVC/1/root/" & sWebVirtualName )
sWebVirtualFrie ndlyName = oVirtualDir.App FriendlyName

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com
Nov 18 '05 #4

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

Similar topics

1
2755
by: md | last post by:
I recently installed Windows XP SP2 (Had no problems with it at all FWIW). One of the applications I am writing has a server piece that communicates on a TCP/IP port that is blocked by default in SP2. When I tried to run the server the firewall asked me if I wanted to make an exception for this application, which I did, and then the app worked just fine. However, if you go into the Windows Firewall and go to the dialog where you can edit...
2
1348
by: Mick White | last post by:
<thead> <tr id="header"> <th><a href="#" onclick="sortTable('rhinos',this.id,sortNumerical);" id="col0" >#</a></th> <th><a href="#" onclick="sortTable('rhinos',this.id,sortByPosition);" id="col1">P</a></th> <th><a href="#" onclick="sortTable('rhinos',this.id,sortByLastNames);" id="col2">NAME</a></th>
8
4505
by: Steve | last post by:
Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini files like the name of a database or connection string. I have read several articles indicating that .config files are now used, but I am confused because they are read- only. If I want to write information from within the application (When a...
2
6778
by: Sven Wynsberghe | last post by:
Like the topic states, is there any way I can get the ip-adress of my computer with a vb.net application? thanks for the help :)
2
1756
by: Rick Derthick | last post by:
Hello, I'm adding a logging capability to error handler routines for troubleshooting (using vb.net) and had just recently come across a way to programatically determine the name of the subroutine or function. For example... Private Sub SomeRoutine() Dim strRoutineName
5
2657
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are simply working with objects in memory. So, it appears as though Microsoft requires that our datamapper classes reside inside a folder called "App_Code", and NO WHERE ELSE. So, has anyone successfully been able to place their datamappers in a...
9
46777
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm using automation and it's working fine when I run it from my local machine. but if I try to access it from another machine it's giving me this Error: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
2
2936
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am using ASP.Net 2.0 and VB.Net (although C#is ok also). I want to create an object/method/function that will take a URL as an input parameter and then return all of the HTML in that page. I also want to return the HTTP header information (response object). Does anyone have an insight as to any code samples or .Net objects I would use to accomplish this?
4
1885
jhardman
by: jhardman | last post by:
Say I have a hypothetical db table of images, one column might be a name, one a url with the source of the image (the images aren't blobs in the db, just referenced) and a column with a category such as "photorealist", "abstract", "impressionist" etc. On a given search I could return records from one or multiple (or no) categories, depending on the search terms. With me so far? What if I wanted to pull up one record (first record that...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10025
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6804
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.