Running 32-bit or 64-bit IIS Express

IIS Express runs x86 / 32-bit as standard, but there is also a 64-bit version.

 

The version used for all web projects can be configured in Visual Studio 2013 or 2015 in the Tools -> Options… dialog.

Under: Project and Solutions -> Web Projects

The setting is:  Use the 64 bit version of IIS Express for web sites and projects

visual_studio_options_web_projects

 

I encountered this while trying to debug some startup and initialization issues with IIS Express and Visual Studio.

The result from:

Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)

Was the path: C:\Program Files (x86)

But I was expecting the path: C:\Program Files

This was a clear sign that IIS Express was running as x86 / 32-bit.

 

Found the Visual Studio setting here:

https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/3254745-allow-for-iis-express-64-bit-to-run-from-visual-st

Other possible solutions are to modify the registry or calling the desired version of IIS Express with a script.

Register WCF for IIS

I encountered problems when testing this code example on a newly installed server (Windows Server 2012 R2):

Consuming a WCF Service from an SSRS (RDL) Server Report

 

I got this error:

HTTP_Error_404.17

HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.

Most likely causes:
The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.

 

Relevant Windows features were already installed.

 

Resolved the problem by running this in a command prompt:

cd "C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation"

ServiceModelReg.exe –i

 

However this was not an ideal solution, because it broke newer sites with:

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

 

Tried fixing it by running:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>  aspnet_regiis.exe -iru

 

Unfortunately that failed with:

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.

 

Eventually I found the solution here: WCF on IIS8; *.svc handler mapping doesn’t work

 

Resolved the problem by running:

dism /Online /Disable-Feature /Featurename:IIS-ASPNET45

dism /Online /Enable-Feature /Featurename:IIS-ASPNET45 /all

dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation

dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation45

 

Also had to follow the advice from the Microsoft article:

Error message after you install the .NET Framework 4.0: “Could not load type ‘System.ServiceModel.Activation.HttpModule'”

By modifying the configuration file:

%windir%\system32\inetsrv\config\Applicationhost.config

With:

<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv2.0" />

 

After this both the old (.NET 3.5) and newer (.NET 4.5+) sites were functional.