Registering ASP.NET 4.5 with IIS8

In Windows Server 2012, DotNet 4.5 are shipped as part of OS but DotNet 4.5 is not registered with IIS8 be default. If you try to run aspnet_regiis.exe as you did for Windows Server 2008 R2, you will see following error

Microsoft (R) ASP.NET RegIIS version 4.0.30319.17929
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Start installing ASP.NET (4.0.30319.17929).
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.
Finished installing ASP.NET (4.0.30319.17929).

Solution

(Following step by step tutorials are copied from IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5 )

Step by Step Instructions enabling AspNet on IIS8

Continue reading Registering ASP.NET 4.5 with IIS8

HTTP Error 404.13 – Not Found Error When Upload Big File using WCF

On IIS 7.5, if you upload big file thru WCF service, you might get http 404.13 error from IIS server.

HTTP Error 404.13 – Not Found
The request filtering module is configured to deny a request that exceeds the request content length.

The solution is set a higher value for maxAllowedContentLength in web.config of application

<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="300000000"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>

IIS 7.5 Error The temp directory in chart handler configuration is not accessible

If you build a web application with Chart control for ASP.NET 4.0 and deploy the site to web server.  You might get following error on the live site:

The temp directory in chart handler configuration is not accessible

To resolve this, first go to web.config and find the ChartImage directory in appsettings.

<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:TempImageFiles;" />
</appSettings>

The go to the temp chart image directory and grant read and write permission to IIS working process account in share properties – security tab. Note that the account runs IIS working process is different between IIS 7 and IIS 7.5

  • On Windows Server 2008 has IIS7, grant Read and Write permission to Network Service
  • On Windows server 2008 R2 has IIS 7.5, grant Read and Write permission to AppPool<PoolName>. Replace <PoolName> to the actual machine pool your site is running on, for example, if your site is running on pool named ASP.NET v4.0, then the account you need grant permission would be IIS AppPoolASP.NET v4.0, you can refer this step by step instructions for detail

Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list

You might see following error when browse your application site targeting ASP.NET 4.0 on IIS 7 or 7.5 server.

HTTP Error 500.21 – Internal Server Error
Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list

Cause & Solution

If IIS is enabled after DotNet 4 installation then ASP.NET is not registered with IIS. You will see the error if your site is targeting ASP.NET 4. To resolve this issue, run the following from elevated command line to register ASP.NET 4:

aspnet_regiis.exe –i

This will register asp.net with IIS. The aspnet_regiis.exe file can be found in either

  • %windir%Microsoft.NETFrameworkv4.0.30319
  • %windir%Microsoft.NETFramework64v4.0.30319 (on a 64-bit machine)

More info for ASP.NET IIS Registration Tool (Aspnet_regiis.exe) can be found at http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx

Run IIS in 32-bit mode on a 64 bit machine

IIS 7 / 7.5 / 8

On IIS 7 / 7.5 / 8,  configure website or web application to run under 32 bit mode can be configured by opening a command prompt and typing following command and press ENTER.

%windir%system32inetsrvappcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true

You can achieve the same goal in IIS Manager by opening the ‘Advanced Settings’ on the application pool binded to the website/web application you want to run under 32 bit mode and change “Enable 32-bit Applications” to True

Enable 32 bit applications in IIS 7

Click okay and now the web application or website you configured will run under 64-bit mode always.

IIS 6

For IIS6 on Windows Server 2003, configure ASP.NET to run in 32 bit mode on a 64 bit windows server.open a command prompt and type following command and press ENTER.

cscript //nologo %SYSTEMDRIVE%InetPubAdminScriptsadsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1

In IIS 6, you cannot run one Application Pool in 32-bit and others in 64-bit. But you can do this on IIS 7 and later as Enable32BitAppOnWin64 can be configured per application pool since IIS 7.  

Grant Permission to DefaultAppPool Identity

After upgrading web applications to IIS 7.5 on Windows Server 2008 R2, you might get following error.

Access to the path ‘d:sitecache.txt’ is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path ‘d:sitecache.txt’ is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate=”true”/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose “Properties” and select the Security tab. Click “Add” to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Continue reading Grant Permission to DefaultAppPool Identity

Make IIS 7.5 application pools run as NETWORK SERVICE

There is a break change in IIS 7.5 on Windows 7 and Windows Server 2008 R2. The default identity for running an application pool is "ApplicationPoolIdentity".  If you have a web application developed against application pools running with NETWORK SERVICE on IIS6/7, it might break after migrated to IIS 7.5 due to default application pool identity change.

Continue reading Make IIS 7.5 application pools run as NETWORK SERVICE