0

If you have an application pool name and you can therefore retrieve this application pool is there any way to retrieve the applications or sites associated with this application pool programmatically? I would settle for just getting a number to basically identify if the application pool is being used but it would be nice to also be able to identify the name of the application / site that is using it as well if possible.

I came across this question but it seems to do it by looping through the existing applications. It doesn't address sites, though that shouldn't be tricky as I can use site.ApplicationDefaults.ApplicationPoolName. However, is there a 'clean' way of getting a collection of applications / sites if you have the app pool name?

Community
  • 1
  • 1
sr28
  • 4,728
  • 5
  • 36
  • 67
  • I think you already find the solution: the accepted answer of the question you provided addresses sites & applications. – Nicolas R Aug 21 '14 at 13:39
  • @NicolasR - that answer seems a roundabout way of doing it. Using that method I'd have to check the application name of each application to see if it matches the 1 I have and then verify if the application / site is running. If possible I'd rather get the applications using the app pool using the app pool name. – sr28 Aug 21 '14 at 13:48
  • 1
    Take a look at the 2nd scenario here: http://blogs.msdn.com/b/jaskis/archive/2010/07/22/using-microsoft-web-administration-to-print-out-application-in-apppool-and-appdomain-in-worker-process.aspx You can use the `WorkerProcesses` property of the ApplicationPool object, but it will not reflect every item, only those loaded – Nicolas R Aug 21 '14 at 13:53
  • @NicolasR - that's a useful link, but sadly I can't guarantee the application will have had a request and therefore be loaded. Looks like I'll have to use the looping method. Just seems a but silly if you already have the app pool. – sr28 Aug 21 '14 at 14:01
  • Yes I think the other SO solution was the only way to do it, sorry. I may move my comments to an answer! – Nicolas R Aug 21 '14 at 14:02
  • @NicolasR - I already knew about the looping method, which I already stated in my question, so if that's what you're going to post then I'm unlikely to mark it as an answer, sorry:) However, I did upvote your comment with the link as I did find it useful albeit not what I was looking for. – sr28 Aug 21 '14 at 14:07
  • I was just talking about replying with an argumented answer showing that 'no, you can't avoid using the loop solution you looked at' – Nicolas R Aug 21 '14 at 14:08
  • @NicolasR - fair point. By all means put that down. However, you may have to wait a bit before I mark it as an answer as I don't know for definite yet. Feel free to prompt me in a couple of days if I've not had any further answers to the contrary. – sr28 Aug 21 '14 at 14:11
  • I'm not running under SO reputation and as you said, maybe someone will find another solution (and the other question is already there), so I will pass my turn – Nicolas R Aug 21 '14 at 14:13
  • @NicolasR - ok, though is you find more evidence supporting the argument that it's not possible that would be useful and stop me searching, so definitely worth posting as an answer then. Thanks for your help so far. – sr28 Aug 21 '14 at 14:15

1 Answers1

0

After much time searching I couldn't find a specific way other than looping as suggest in my question. This was reiterated by Nicolas R.

sr28
  • 4,728
  • 5
  • 36
  • 67