Retrieving IIS App Name

  • Thread starter Thread starter Doug Thews
  • Start date Start date
D

Doug Thews

How can I retrieve the IIS Application Name (set using the IIS MMC Manager)
within an ASP.NET application? I tried using AppDomain.GetData("APP_NAME"),
but that appears to be just a hex string associated with the dynamic id
created by ASP.NET when creating app domains and names within the app
domains.
 
Hi Doug,

The name seems to be embedded in the FriendlyName property. Not sure if you
can parse it out.

Dim currentDomain As AppDomain = AppDomain.CurrentDomain
Label1.Text = currentDomain.FriendlyName

Also, there seems to be a way to get this kind of info from the metabase.
You might want to look here for ideas:

http://www.iisfaq.com/default.aspx?View=A540&P=199

Ken
MVP [ASP.NET]
 
Ken,

Friendly name has the virtual root name embedded, but not the application
name that you can give via the IIS Manager. For example, here's my IIS
Application Name set in IIS: MyTestVBWebApp. The virtual directory is
called TestVBWebApp. I made them different to make sure I was getting the
value that I set in IIS, and not just the name of the virtual directory.

Anyway, the FriendlyName property comes out to be:
/LM/w3svc/1/root/TestVBWeb App-3-127252855483045295.

I think I have to look outside of the AppDomain class because of the way
ASP.NET sets these up dynamically (multiple ASP.NET web apps can be inside
the same App Domain). I'm looking for something that reflects on the IIS
settings for the current ASP.NET web app.

I also worry about going straight against the metabase because it might not
work across IIS5/IIS6 platforms, but I'll see what I can do.

Thoughts??

--
Doug Thews
Director, Customer Solutions
D&D Consulting Services
----------------
Visit my Tech Blog at:
http://www.ddconsult.com/blogs/illuminati/



Ken Cox said:
Hi Doug,

The name seems to be embedded in the FriendlyName property. Not sure if you
can parse it out.

Dim currentDomain As AppDomain = AppDomain.CurrentDomain
Label1.Text = currentDomain.FriendlyName

Also, there seems to be a way to get this kind of info from the metabase.
You might want to look here for ideas:

http://www.iisfaq.com/default.aspx?View=A540&P=199

Ken
MVP [ASP.NET]
 
Back
Top