Iis – run .NET4 applications within a .NET3.5 website

.net-4.0iis

I have a very large and complex web application running .NET 3.5, with some classic ASP pages and VBScript components thrown in for good measure. The site is running on IIS7, and is a root website.

Ideally, I'd like to have a sub-application beneath this website which runs .NET 4, to deploy new components. However, this is presenting me with difficulties and the following error is showing:

The value for the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework. To compile this Web application for version 3.5 or earlier of the .NET Framework, remove the 'targetFramework' attribute from the element of the Web.config file.

Is this going to be possible at all, or should I give up and find another way?

Best Answer

It is possible.

You need of course to have both frameworks installed on the web server; then, you will need to configure the site's root to run using the 3.5 framework, and the folder (or virtual directory) where your sub-application resides to run using 4.0. You will need at least two appplication pools, one for 3.5 and the other for 4.0; you can use the default ones (they are created automatically when registering the frameworks with IIS) or create custom ones, it depends on the server's configuration.

If the sub-application is unrelated to your main site, this should be enough; if they need to "talk", things will get somewhat trickier, as the main site and the sub-application will actually run in two completely different runtime environment, even if they reside in the same web site structure.

Related Topic