2

Is it possible to have two virtual directories under the same website in IIS but have the virtual directories be using different versions of the .net framework?

For example, under the default website, can I have one virtual directory targeting the 2.0 framework and a second virtual directory targeting the 1.1 framework?

This is for IIS 6, thanks!

Chris Conway
  • 16,269
  • 23
  • 96
  • 113

3 Answers3

5

You are not saying which version of IIS you are using, but for 6.0 and up, just assign them to different application pools, and set the pools to use the right version of .Net.

Sunny Milenov
  • 21,990
  • 6
  • 80
  • 106
  • Note that this means you can no longer use the IIS in XP for testing. – Joel Coehoorn Nov 12 '08 at 16:35
  • No really. Application pools are new to 6.0, as is the new process model. In XP, each application runs in its own process (if you configure it so - Isolation level). And you can set the framework version using the tab in the properties section. – Sunny Milenov Nov 12 '08 at 16:52
  • I edited the question to specify that this is for IIS 6. Thanks! – Chris Conway Nov 12 '08 at 20:21
  • Will this also work with a .NET 4.0 application in a Virtual Directory underneath a .NET 2.0 website? (Also IIS 6) – Valien Jul 14 '11 at 16:04
  • @Valien, the version of .Net, used by a virtual director can be set independently for each virtual directory. As in the answer - you need separate AppPool for each version of .Net. So, if you have 2 virtual directories - one using 2.0, and one using 4.0, you will need 2 AppPools, and set each virtual dir to a different one. – Sunny Milenov Jul 14 '11 at 18:51
  • Hey Sunny - thanks for the reply. I just setup a test site as a virtual directory with a 4.0 app pool assigned to it. The master site is a 2.0 site. When I try to view the site I get an http handler error from the main site config. Basically saying that `` could not be loaded. The handler (ashx) is part of the root site, not my virtual directory. Thoughts? – Valien Aug 05 '11 at 14:13
  • do you want to use that handler? if not, then just check your web.config and remove the line. If you want, then start new question with more details about your situation. – Sunny Milenov Aug 05 '11 at 14:45
1

You have to create an "application" for both of the virtual directories, and then you'd assign their ASP.NET version using the ASP.NET tab under web site properties.

Also, as @sunny mentioned, you'd need to have two different application pools, and each virtual directory would have to be pointed to a different application pool. Because different versions of ASP.NET cannot run within the same application pool.

Brian G Swanson
  • 1,039
  • 7
  • 17
0

It depends if you mark them as "applications". Application virtual directories can use different framework. Make sure you associate them to different application pools. Never mix two .NET framework versions in one application pool.

One important note: if you create a virtual directory as an application, you don't share session state and other application related objects. Also Server.MapPath("~") and other ServerURL related methods an properties will point to the physical directory of the virtual directory and not to the main root.

splattne
  • 102,760
  • 52
  • 202
  • 249