Sel_va
Sel_va

Reputation: 608

The pattern of application ID in a .Net

When i get the application id of a request by using below code:

string appID = System.Web.Hosting.HostingEnvironment.ApplicationID;

I am getting the appID as

/LM/W3SVC/1/ROOT/MvcMusicStore

My main motive is to get the website ID from this.. It resides after W3SVC. (1 is the website id in this case).

i need to confirm with the geeks over here will the application ID's output will be in this pattern only.?

So that it will not be a issue for me if a implement a generic string parsing and take the number that comes after 9th position in the string. Or will the pattern vary w.r.t the IIS version or some other factor. ?

Upvotes: 1

Views: 1093

Answers (1)

Sami Kuhmonen
Sami Kuhmonen

Reputation: 31153

When running the application under IIS is always of that format, it doesn't change. If you don't need to run it under any other platform, you can take that value.

The ID is based on the metabase path, which was used in IIS earlier, but even though the metabase is no longer used in the current IIS versions, the AppliationID is still the same (even tested with Windows Server 2012 R2's IIS).

Upvotes: 1

Related Questions