tags:

views:

882

answers:

2

Hello,

I have made a user control in asp.net c#. Becuase of some data I need to retrieve I would like to get the site id that is used for this site in iis. Is this possible, and if so, how?

Thanks!

+1  A: 

If it helps, one option here is to use the <location path="site-id">...</location> in the global web.config (i.e. the one in the framework folder) to specify different configuration options for different sites, such as different app-settings, connection-strings, etc.

Marc Gravell
@Marc: did you respond the the correct question? I can't make your answer fit this question.
John Saunders
Yes; in concept: rather than identify the site and code on the site name, *configure* the site and use values from configuration.
Marc Gravell
+2  A: 

This will give you the site ID:

Request.ServerVariables[ "INSTANCE_ID" ]

If you just need to get it once then you can lookup the log file path in the IIS MMC. The number after the "W3SVC" part is also the site id.

David