21

Pieces of the puzzle:

  • Windows 7
  • .NET Framework 4.5 (installed)
  • IIS 7(Version 7.5.7600.16385)
  • Visual Studio (Ultimate 2013)
  • MVC4 (multiple projects in the solution)

The solution I'm running in Visual Studio works and runs as expected with IISExpress.

To set up my site to use IIS, I tried the following steps:

  1. Right-click the projects in the solution that are currently being hosted by IISExpress.
  2. Click Properties.
  3. Toggle the Servers drop-down from IISExpress to Local IIS
  4. Try to build/run the application

At this point, I get an HTTP 500.21 error.

I have also tried to run aspnet_regiis.exe -i using Visual Studio's command prompt (as an Administrator), but each time I run the command, I receive the following error:

Command 'aspnet_regiis.exe' is not valid.

I also confirmed that I do have the right aspnet_regiis.exe installed (by checking here) (.NET Framework version 4 (64-bit systems)).

What do I need to do to register .NET Framework 4.5 in IIS 7.5?

Ryan Kohn
  • 11,921
  • 10
  • 50
  • 80
id.ot
  • 2,641
  • 1
  • 28
  • 45
  • 1
    I also hit this after I installed the VS2015 CTP. The fix for me was to uninstall the CTP, along with the .NET preview version it brought with it. I then reinstalled .NET 4.5.1 and the message went away. – ChaseMedallion Jan 12 '15 at 14:25

5 Answers5

26

You can find the aspnet_regiis in the following directory:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

Go to the directory and run the command form there. I guess the path is missing in your PATH variable.

Peter
  • 26,307
  • 7
  • 58
  • 80
  • 2
    Per the [link](http://msdn.microsoft.com/en-US/library/k6h9cz8h%28v=vs.100%29.ASPX#findingthecorrectversion) in my original post I already knew that I had the correct version of _aspnet_regiis.exe_ but what the documentation doesn't plainly (if at all) state is what you (@peer) explained in your response. The fix for me was to 1) open _cmd_ as an administrator. 2) `cd \Windows\Microsoft.NET\Framework64\v4.0.30319` 3) `aspnet_regiis.exe -i`. Good to go, thank you! – id.ot Jun 04 '14 at 17:43
9

Hosting asp.net 4.5/4.5.1 Web application on Local IIS 1)Be Sure IIS Installation before Visual Installation Installataion then aspnet_regiis will already registerd with IIS

If Not Install IIS and then Register aspnet_regiis with IIS by cmd Editor

For VS2012 and 32 bit OS Run Below code on command editor :

1)Install IIS First & then

2)

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319   

  C:\Windows\Microsoft.NET\Framework\v4.0.30319> aspnet_regiis -i

For VS2012 and 64 bit OS Below code on command editor:

1)Install IIS First & then

2)

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319    
  C:\Windows\Microsoft.NET\Framework64\v4.0.30319> aspnet_regiis -i

BY Following Above Steps Current Version of VS2012 registered with IIS Hosting (VS2012 Web APP)

Create VS2012 Web Application(WebForm/MVC) then Build Application Right Click On WebApplication(WebForm/MVC) go to 'Properties' Click On 'Web' Tab on then 'Use Local IIS Web Server' Then Uncheck 'Use IIS Express' (If Visul Studio 2013 Select 'Local IIS' from Dropdown) Provide Project Url like "http://localhost/MvcDemoApp" Then Click On 'Create Virtual Directory' Button Then Open IIS by Prssing 'Window + R' Run Command and type 'inetmgr' and 'Enter' (or 'OK' Button) Then Expand 'Sites->Default Web Site' you Hosted Successfully. If Still Gets any Server Error like 'The resource cannot be found.' Then Include following code in web.config

 <configuration>
     <system.webServer>
         <modules runAllManagedModulesForAllRequests="true"></modules>

And Run Application

If still problem occurs Check application pool by : In iis Right click on application->Manage Application->Advanced setting->General. you see the application pool. then close advance setting window. click on 'Application Pools' you will see the all application pools in middle window. Right click on application pool in which application hosted(DefaultAppPool). click 'Basic Setting' -> Change .Net FrameWork Version to->.Net FrameWork v4.0.30349

Dnyneshwar
  • 610
  • 8
  • 9
4

For Windows 8 and Windows Server 2012 use dism /online /enable-feature /featurename:IIS-ASPNET45 As administrative command prompt.

Bhaskar Singh
  • 375
  • 5
  • 14
1

I got into this mess twice and after searching long and hard and following what others did absolutely nothing worked for me but to uninstall and install IIS back once on Windows 7 machine and then on Windows server 2012 R2.

user2913184
  • 566
  • 10
  • 29
  • 1
    Thanks for the tip however the original post doesn't use or mention Windows Server 2012 R2. – id.ot Jan 24 '17 at 18:37
-1

use .NET3.5 it worked for me for similar issue.

Vaibhav
  • 123
  • 4
  • 14