Knowledgebase : IIS

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


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.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.

Solution:

To resolve this issue, run the following from command line:

aspnet_regiis.exe /iru

The aspnet_regiis.exe file can be found in either

  • %windir%\Microsoft.NET\Framework\v4.0.30319
  • %windir%\Microsoft.NET\Framework64\v4.0.30319 (on a 64-bit machine)


The following article explains how to install ASP.NET on a Windows server. ASP.NET is a scripting language that is designed to run in a Windows Environment. 

To install ASP.NET on a server running Windows .NET using the Configure Your Server wizard

  1. From the Start menu, click Manage Your Server; in the Manage Your Server window, click Add or remove a role.
  2. In the Configure Your Server wizard, click Next, and in the Server Role dialog box, check Application Server (IIS, ASP.NET) and then click Next.
  3. In the Application Server Options dialog box, select the Enable ASP.NET check box, click Next, and then click Next again.
  4. If necessary, insert your Windows .NET Server 2003 installation CD in the CD-ROM drive and then click Next.
  5. When the installation is complete, click Finish.

To install ASP.NET on a server running Windows .NET using the Add or Remove Programs dialog box

  1. From the Start menu, point to Control Panel, and then click Add or Remove Programs.
  2. In the Add or Remove Programs dialog box, click Add/Remove Windows Components.
  3. In the Components box in the Windows Components wizard, select the Application Server check box, and then click Next.
  4. When the Windows Components wizard has finished configuring Windows .NET Server 2003, click Finish.

To enable ASP.NET in IIS Manager on a server running Windows .NET

  1. From the Start menu, click Run.
  2. In the Open box in the Run dialog box, type inetmgr, and then click OK.
  3. In IIS Manager, expand the local computer and then click Web Service Extensions.
  4. In the right pane, right-click ASP.NET and then click Allow. The status of ASP.NET changes to Allowed.


You can enable trace logging for failed requests when you want to log information about failed requests to an IIS site or application. When trace logging for failed requests is enabled, IIS provides targeted logging so that you no longer have to look through a list of irrelevant log entries to find a failed request. Additionally, you do not have to re-create an error in order to troubleshoot it.

You can configure:

  • The location of the log file
  • The maximum number of log files to keep
  • The maximum size of the log files

To enable site-level trace logging for failed requests

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

User Interface

To Use the UI
  1. Open IIS Manager and navigate to the level you want to manage. 

  2. In the Connections pane, click Sites.

  3. In Features View, select the site for which you want to enable trace logging.

  4. In the Actions pane, under Configure, click Failed Request Tracing.

  5. In the Edit Web Site Failed Request Tracing Settings dialog box, select Enable to enable logging for this site.

  6. In the Directory text box, type the path where you want to store the log files or click the browse button () to find a location on the computer. The default is %SystemDrive%\inetpub\logs\FailedReqLogFiles.

HTTP Error 500.21 - Internal Server Error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list. 

Solution:

Run "aspnet_regiis.exe" program from command line (within Command Prompt):

run %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe –i

 Note: if your computer is 64 bit, then use the following:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe –i

Restart IIS.

If above solution does not work for you try the other method below:

Click Start -> All Programs -> Accessories -> Run
In the Open textbox paste in the following line

For silent repair on 32 bit computer with .Net Framework version 4.0.30319 use:
%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart

For silent repair on 64 bit computer with .Net Framework version 4.0.30319 use:
%windir%\Microsoft.NET\Framework64\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart

Click OK to start the repair
After, the repair ran for a few minutes, restart IIS.

 

On Windows Server 2008 IIS 7.5

You can add rewrite rule in web.config file to redirect domain.com to www.domain.com

Option 1:

<system.webServer>
<rewrite>
   
<rules>
     
<rule name="Canonical host name">
       
<match url="^(.*)" />
         
<conditions>
           
<add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
         
</conditions>
       
<action type="Redirect" url="http://www.domain.com/{R:1}" />
     
</rule>
   
</rules>
</rewrite>
</system.webServer>

Option 2:

<system.webServer> <rewrite> <rules> <clear /> <rule name="WWW Rewrite" enabled="true"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$" /> </conditions> <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" /> </rule> </rules> </rewrite> <system.webServer>

Multipurpose Internet Mail Extensions (MIME) types instruct the user's Web browser to open a specific program for a file extension. MIME types are sometimes customized file types created by the website programmer. The MP4 MIME type is a video type, and it is configured in Internet Information Services (IIS) console. This instructs the user's Web browser to use the default video application when running this file from the website pages.  

  1. Click Windows "Start" button. Click "Programs" and then click "Administrative Tools." In the list of menu options, click "Internet Information Services Manager." This opens the IIS console.
  2. Click the name of your IIS Server on the left panel. This enables several options in the central details pane. Double-click the icon labeled "MIME Types." On the right panel, click the "Add" link. This opens a configuration dialog box.
  3. Enter ".mp4" into the "File Name Extension" text box. In the "MIME Type" text box, enter "video/mp4." Then click the "OK" button.
You may need to restart Internet Information Services (IIS) before certain configuration changes take effect, or when applications become unavailable. Often, the first step in troubleshooting issues with your website is to restart IIS. Follow the instructions below to restart IIS.

  1. 1. From the Start menu, click Run.
  2. In the Open box, type cmd, and click OK.
  3. At the command prompt, type iisreset /stop. IIS will attempt to stop all services and will return confirmation once all services have been stopped.
  4. At the command prompt, type iisreset /start. 
When you visit a Web site that is hosted on Internet Information Services (IIS) 7.0, you receive an error message that resembles the following:
Server Error in Application "Application Name"
HTTP Error 403.6 - IP Address Rejected
HRESULT: 0x80070005
Description of HRESULT
# General access denied error
To resolve this problem, follow these steps:
  1. In a text editor, open the ApplicationHost.config file.
    Note The ApplicationHost.config file is located in the following folder:
    %SystemRoot%\system32\inetsrv\config
  2. Locate the ipSecurity XML element, and then set the value of the allowUnlisted property to true.
After you follow these steps, IIS accepts requests from any IP address that does not appear in the list of IP addresses under the ipSecurity XML element.

Note The security level of the server that is running IIS may be decreased when you enable IIS to accept requests from any IP address.

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

Scenario:

  • You have migrated your web site from IIS 6.0 to IIS 7.0
  • You are trying to change ASP.Net version from 2 to ASP.Net Version 4
  • You are trying to upgrade your DotNetNuke Version (Ver.5 and up)

Description:

The 404.17 error indicates dynamic content mapped to the static file handler but that handler mapping does not apply for the current pipeline mode (integrated/classic), bitness (32/64 bits) or even asp.net version. The pre-selected setup defaults of IIS 7.0 only provide the IIS modules required to support static content, you would normally need to have multiple mappings to asp.net for any extensions for it to work across all possible combinations of those things.

Solution:

  • Please make sure the .Net Framework 4.0 installed on your IIS server. If you have installed .Net Framework 4.0 on your IIS server, please run "aspnet_regiis -i" in C:\Windows\Microsoft.NET\Framework\v4.0.21006

If above does not work for you, do the following

  • Open IIS
    • Expand IIS Server from Left Menu
    • Expand "Sites"
    • Click on the website name you are having issue with
    • Double Click to open "Handler Mappings"

 

 

 

 

 

 

 

    • Under "ACTION" menu Click "Revert to Parent"
  •  

     

By contrast, in IIS7 & 7.5 (Windows Server 2008 & Server R2), adding the same mime types at the application level (which IIS will place into a web.config file) and the site level (which IIS will place into the applicationHost.config file) may cause a conflict.  No warning is given except for an error in the client browser that goes something like this:

Server Error in Application

Internet Information Services 7.0
HTTP Error 500.19 - Internal Server Error

 

MIME Types

There was an error while performing this operation.
Details
Filename
\\?\c:\something\something\.....\web.config
Line number: 25
Error: cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.xyz’

Solution:

One solution would be to simply remove one of the two conflicting mimeMap extensions from one of the config files.  However, in some rare scenarios the IIS administator may need to not remove one of the two conflicting mime mappings.  If both mimeMaps are needed, the way to get around the conflict is to make one simple addition to the web.config which will do a REMOVE immediately prior to doing an ADD.

So if your application installation adds the following line to the web.config. . .

           <mimeMap fileExtension=".xyz" mimeType="xml/text" />

… And this line creates a conflict with the same mime map in the applicationhost.config file, all you have to do is add the following line ABOVE that line so that it will look like the following:

           <remove fileExtension=".xyz" />
           <mimeMap fileExtension=".xyz" mimeType="xml/text" />
   
Doing the remove before the add should be fine even when the .xyz mime map doesn't exist at a higher level. 

By contrast, in IIS7 & 7.5 (Windows Server 2008 & Server R2), adding the same mime types at the application level (which IIS will place into a web.config file) and the site level (which IIS will place into the applicationHost.config file) may cause a conflict.  No warning is given except for an error in the client browser that goes something like this:

Server Error in Application
Internet Information Services 7.0
HTTP Error 500.19 - Internal Server Error

MIME Types
There was an error while performing this operation.
Details
Filename
\\?\c:\something\something\.....\web.config
Line number: 25
Error: cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.xyz’

Solution:

One solution would be to simply remove one of the two conflicting mimeMap extensions from one of the config files.  However, in some rare scenarios the IIS administator may need to not remove one of the two conflicting mime mappings.  If both mimeMaps are needed, the way to get around the conflict is to make one simple addition to the web.config which will do a REMOVE immediately prior to doing an ADD.

So if your application installation adds the following line to the web.config. . .

           <mimeMap fileExtension=".xyz" mimeType="xml/text" />

… And this line creates a conflict with the same mime map in the applicationhost.config file, all you have to do is add the following line ABOVE that line so that it will look like the following:

           <remove fileExtension=".xyz" />
           <mimeMap fileExtension=".xyz" mimeType="xml/text" />
    
Doing the remove before the add should be fine even when the .xyz mime map doesn't exist at a higher level.