IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 : The Official Microsoft IIS Site

2013 年 6 月 18 日5080

IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5

By

February 29, 2012

Compatibility

Version Notes IIS 8.0

ASP.NET 3.5 and ASP.NET 4.5 are supported on IIS 8.0.

IIS 7.5

ASP.NET 3.5 and ASP.NET 4.5 are supported on IIS 7.5.

IIS 7.0

ASP.NET 3.5 and ASP.NET 4.5 are supported on IIS 7.0.

Contents

Problem

Windows Server 2012 includes .NET Framework 4.5 by default, as well as optional installation of the .NET 3.5 Framework. Developers frequently need to run mixed web applications across multiple .NET Framework versions.

Solution

IIS 8.0 on Windows Server 2012 runs ASP.NET applications on all .NET Framework versions supported on Windows Server 2012. This means ASP.NET applications can run on IIS 8.0 using either .NET Framework 3.5, or .NET Framework 4.5. IIS 8.0 hosts versions of the .NET Framework in different application pools, thus allowing multiple ASP.NET applications with different .NET Framework versions to run simultaneously on Windows Server 2012.

IIS 8.0 also supports managing both ASP.NET 3.5 and ASP.NET 4.5 applications using both the graphical IIS Manager tool as well as IIS' command-line management tools. Refer to this article for more information.

Step by Step Instructions

Prerequisites:

IIS is installed on Windows Server 2012. To learn more about installing IIS 8, see Installing IIS 8 on Windows Server 2012.

Setting up IIS 8.0 with support for ASP.NET 3.5 and ASP.NET 4.5

In Windows Server 2012, both the .NET Framework 3.5 and .NET Framework 4.5 are natively recognized by the operating system. This means both UI-based and command-line driven setup can be used to turn on both versions of the .NET Framework, as well as enabling integration of both versions of ASP.NET with IIS 8.0.

For this walkthrough we will use the new Server Manager UI in Windows Server 2012 Server to demonstrate enabling both ASP.NET 3.5 and ASP.NET 4.5 on IIS 8.0.

    The Application Development node is where we enable ASP.NET integration with IIS. Note that there are a few checkboxes in the feature list with similar names. The pair of checkboxes that are of interest for this walkthrough are:

Exploring the IIS 8.0 Installation

With both IIS 8.0 and ASP.NET integration installed we can take a look at the basic ASP.NET footprint for IIS 8.0.

    You can see that six different application pools are created by default when both ASP.NET 3.5 and ASP.NET 4.5 are enabled for IIS 8.0. Four of the applications are new for IIS 8.0, while two other application pools have been carried forward from previous Windows releases.

Running both ASP.NET 3.5 and ASP.NET 4.5 Applications

Now that you have explored the setup state of IIS 8.0, try running some sample ASP.NET code to confirm that both ASP.NET 3.5 and ASP.NET 4.5 applications can run simultaneously on a single IIS 8.0 installation.

Sample code for both ASP.NET 3.5 and ASP.NET 4.5 is contained in the following .zip:

First, set up a simple ASP.NET 3.5 application on IIS 8.0:

    At this point start an instance of Internet Explorer and navigate to the following Url:

    http://http://www.zjjv.com// Framework features supported in this application.

    in Windows Explorer, if you navigate to the "c:\inetpub\http://www.zjjv.com/ Framework compilers to run in "3.5" mode. The .NET Framework code in "default.aspx" demonstrates some C# constructs that were introduced in .NET 3.5 - specifically LINQ-to-Object queries.

Now that there is an ASP.NET 3.5 application running, you can create a second ASP.NET application, but this time configure it to use .NET 4.5.

    Now go back to Internet Explorer and navigate to the following Url:

    http://http://www.zjjv.com// 4.5 application for the "Default Web Site". The browser once again displays a list of .NET Framework features supported in this application with a new entry at the end of the list for dynamically typed variables (i.e. the dynamic keyword introduced in .NET 4.0/4.5). Notice that unlike the "example35" application that required special web.config entries, no web.config file was required to configure and run the "default.aspx" page in the "Default Web Site". This is because .NET Framework 4.5 is the default .NET Framework used by ASP.NET applications in IIS 8.0, and as a result no extra configuration is required.

    If you use Notepad to open the "default.aspx" page that you just copied, you will also see a few changes compared to the version in the "example35" directory. There are no namespace directives at the top of the page since the .NET Framework 4.5 is the default on IIS 8.0. The code on the page demonstrates using a dynamic variable, which is a compiler concept introduced in .NET 4.0/4.5.

Summary

IIS 8.0 supports running both ASP.NET 3.5 and ASP.NET 4.5 applications on the same machine using different application pools to host each .NET Framework version. IIS 8.0 supports for multiple .NET Framework versions enables developers and administrators to take full advantage of IIS 8.0 while maintaining backward compatibility with web applications carried over from Windows Server 2008 R2.

ByWon Yoo

Won Yoo

Won Yoo is a program manager in IIS for Microsoft.

Translate this page
Powered by Microsoft Translator

0 0