Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Windows Server 2012 command line equivalent of `aspnet_regiis -ir`?

As documented in several questions (Alternative for the Registering ASP.NET 4.5 on Windows Server 2012; Server 2012 IIS 8 MVC app shows default IIS home page or 403 / 404 errors; WCF on IIS8; *.svc handler mapping doesn't work), on Windows Service 2012 the aspnet_regiis -ir command does not work anymore, and instead produces the following output:

This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.

In our case, we only want to run this command to re-register ASP.NET 4.5, since some other installation un-registered it: ASP.NET 4.5 is installed already.

Using the UI (Add/Remove roles/features), inspired by the referenced posts, I found that it suffices to remove WCF's HTTP Activation feature and then add it again. (But I needed to uninstall/reinstall a feature that happens to depend on WCF HTTP Activation...)

Question: How can this same thing be done through the command line on Windows Server 2012?

(I looked at this dism.exe thing, but it looks daunting, and dism.exe -? didn't help me at all.)

Thanks!

like image 606
MarnixKlooster ReinstateMonica Avatar asked May 13 '13 14:05

MarnixKlooster ReinstateMonica


People also ask

What is aspnet_regiis command?

The ASP.NET IIS Registration Tool (Aspnet_regiis.exe) allows an administrator or installation program to easily update the script maps for an ASP.NET application to point to the ASP.NET ISAPI version that is associated with the tool. The tool can also be used to display the status of all installed versions of ASP.

How to check ASP.NET version in Windows server 2012?

To check that ASP.NET is installed and registered with the correct version, enter the command aspnet_regiis.exe -lv at the command prompt. Version 4.5 should be displayed for ASP.NET.

Where is aspnet_regiis exe located?

The Aspnet_regiis.exe tool is located in the %windows%\Microsoft.NET\Framework\versionNumber folder. You can also use the protected configuration classes in the System.

How do I install ASP.NET 4.5 on Windows 10?

Open the Control Panel, click "Programs" and then click "Turn Windows features on or off" to open the "Windows Features" dialog. 2. Enable ". NET Framework 4.5 Advanced Services > ASP.NET 4.5" (version 4.6 in Windows 10):


2 Answers

Dism would be the best way to do this:

Dism /online /Disable-Feature /FeatureName:WCF-HTTP-Activation45
Dism /online /Enable-Feature /FeatureName:WCF-HTTP-Activation45

Use the /all switch when enabling to enable all parent features.

like image 87
John Cornell Avatar answered Oct 02 '22 14:10

John Cornell


This error seems to occur when you install the .NET framework core feature which is .NET 3.5 over CLR 2.0 including HTTP activation on a Windows 2012 or 2012 R2 server which already had the .NET framework 4.5 version installed.

In our case the suggested fixes did not work.

We had a CLR 4.0 website that was showing the error:

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Removing and re-adding the ASP.NET 4.5 features made no difference.

We had to remove and re-add the 3.5 features using DISM:

Dism /online /Disable-Feature /FeatureName:WCF-HTTP-Activation
Dism /online /Enable-Feature /FeatureName:WCF-HTTP-Activation

You could also use PowerShell:

Remove-WindowsFeature -Name NET-HTTP-Activation
Add-WindowsFeature -Name NET-HTTP-Activation
like image 29
CarlR Avatar answered Oct 02 '22 14:10

CarlR