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

If you are developing on Windows 7 or Vista or for that matter operating system where you have IIS7 installed and have Visual Studio 2008 and Visual Studio 2010 installed, at some point you will run into following error when developing WCF service.


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

You do not receive this error because you have one of the components mentioned above installed or because of the operating system. It is combination of few things that causes this error. I read few posts about this error and could not find a comprehensive explanation and solution. I had to stich together few of those suggestions to come up with final solution and explanation. In this post I will make an attempt to discuss how to diagnose this error, why this occurs and how to fix it.

Diagnosis

One thing that IIS7 does very well is that error descriptions have become little bit more descriptive as compared to previous versions. So if you look at the error, it tells that it something to with file handler for the file type that user is trying to access. In my case I have a WCF service so my file is .svc

Requested URL: http://localhost:80/ProductsSearch/AmazonSearchService.svc 

That was kind of strange to me that I had developed a similar application and WCF service using Visual Studio 2010 and did not get this error. But this time I was developing on Visual Studio 2008. So there was first clue that it has something to do with version of some component. Follow the following steps to see what file handler or mime type handlers are installed for your web site.

  • Bring up IIS manager and you will notice an icon in IIS section that reads Handler Mappings.

  • Double click on this icon and you will see a dialog box that looks like image belong and has listing of all file types and the handlers associated with it. Locate the file type that is throwing error for you. In my case it was .svc file for WCF service. I noticed that there are three file handlers associated with this file type and I am still getting the error.

  • Double click on any of these entries and you will see the details that look like image below. It tells you the assembly or module that is mapped to handle requests for these file types. You will notice that in my case it was pointing to correct ISAPI extension BUT it was pointing to .Net 4.0 framework folder.

The last step made things clear that although I have a file handler for .svc file type, but it is being served by framework version for which my site is not configured. I was developing for ASP.Net 2.0. The solution was just to have correct mapping for correct .Net framework that my web site is mapped to.

Finding Mapped Framework For Your Web Site

Each application in IIS7 is configured to use an application pool. And each of these application pools is assigned to a .Net Framework. When you create an application in IIS7 is gets assigned to Default Application Pool by default untill you change it explicitly. And depending on you have configured application pools, this Default Application Pool may be mapped to ASP.Net2.0 or ASP.Net4.0 depending on what all versions of ASP.Net framework you have installed on your machine. In my case Default Application Pool is mapped to .Net 2.0 framework as you can see from the screenshot below.

Default Application Pool

Fix The Error

There are two steps that you will have to perform the error about mapping to static file handler.

Fix Application Pool

Check the application pool for your application. Make sure that it is configured to correct version of .Net framework. You can always a custom application pool in IIS and then configure your application to use that. You can always configure your application to use Classic .Net AppPool. You can see from following screenshot that it is mapped to .Net 2.0 and configured to use Classic pipe line and not integrated one.

Add or Edit Mapping

There is a good chance that your installation of IIS7 does not have mapping for the file type for .Net framework version that your application is using. Follow the following steps to add a new mapping in IIS for your application.

  • Bring up Mapping Handler dialog box for your web application.

  • In right side pane you will notice a link Add Script Map.

  • Click on that link that will bring up Add Script Map dialog box. Enter the required information to create a new mapping. Pay close attention to the handler module file path. Notice that I have created a new mapping for .svc file that is going to be served by aspnet_isapi.dll from v2.0.50727 folder and not from .Net 4.0 folder.

  • Click OK and you should have new file handler added for your application.

This should fix the error.

Search

Social

Weather

17.1 °C / 62.7 °F

weather conditions Clear

Monthly Posts

Blog Tags