tags:

views:

18

answers:

1

I have a page running on IIS7. I'd like to know the name or at least the ID of the WebApp that the page is running in. For instance, if you have DefaultWebSite>MyWebApp>virtualDirectory>myPage.aspx, I'd like to have a piece of code that runs within myPage.aspx and prints out the string: "MyWebApp", dynamically, depending on the name of the web app it's running in.

I know there is a namespace for IIS7 config, Microsoft.Web.Configuration, but I'm not seeing any way to tie a page to it's web app during runtime. I can enumerate over the different web site collections, but not sure how to tie it back to the running page.

A: 

I believe this blog post has an example of what you are trying to do.

JP Alioto