Install .NET 4 on IIS 7

As with a lot of my posts, a question was asked on StackOverflow how to Setup .NET 4 on IIS 7 (Windows 7). The process is quite simple as the framework takes care of a lot of it for you. It’s just a matter of finding the tools the framework uses and calling them.

Although I already answered it on StackOverflow, I thought I would also post it here with a tad more detail. So, without further ado…

If I describe something you should type, the quotes around the term(s) are unnecessary and are only there to visually display the command that should be type. e.g. If I ask you to type “cmd” all you should be typing is cmd.

  1. Install .NET 4 Framework
    The downloads page can be found directly on Microsoft.com/net, but I’ll make it easy and say it can be found here: http://www.microsoft.com/net/…
  2. Open your command prompt
    1. Open an Elevated Command Prompt
  3. Navigate to the directory where the framework is. For my installation (and I believe most) the following command should work:
    cd %SystemDrive%\Windows\Microsoft.NET\Framework\v4.0.30319
  4. Install the Framework on IIS
    1. type “aspnet_regiis.exe -ir” and press ENTER
      1. If this is a fresh install of IIS or you have sites hosted that won’t be affected by a framework change, you can use the “-i” flag (dropping the “r”). This will effectively make all currently-hosted sites use the new framework.
      2. If you’re curious about “-ir”/”-i”, or what other options are available, please see this MSDN article on aspnet_regiis.exe.
    2. The framework is now beginning to install on IIS.
    3. Once it’s completed, you can close the command prompt.

At this point the framework should be installed on IIS. To confirm, let’s make sure that the application pool successfully installed.

  1. Open IIS Management
    1. Open Start Menu, right-click Computerand select Manage
      1. Like shortcuts? “compmgmt.msc” in the console works, too.
    2. Locate and expand Services and Applications
    3. Select Internet Information Services
      1. You’re now within the IIS applet.
  2. Change the Application Pool(s)
    1. Expand out your computer node under Connections to the left within the IIS applet.
    2. Select the Application Pools node.
    3. Confirm that you see the ASP.NET v4.0 and ASP.NET v4.0 Classic pools.

Now, if you did use the “-ir” flag and need to switch over some sites to use the new framework, perform the following tasks:

  1. Update site to use new application pool
    1. Expand the Sitesnode
      1. You now have a list of all the sites IIS is hosting. Repeat the following steps for each site you’d like to update.
    2. Locate and select (click) the site you’d like to manage.
    3. Click Basic Settings… link on the right hand side in the Actions bar.
    4. Click the Select… button and select the ASP.NET v4.0 AppPool and click OK.
    5. Click OK again to accept the new AppPool.
    6. Restart the website (Restart link to the right below Manage Web Site.

Everything should be good-to-go now, and that site will now run .NET 4.0. If you have any other sites that need changing, follow the last set of instructions for each site you need to update.

Flattr this!