2

I have a web application running on IIS 7 on Windows Server 2008 R2 (Datacenter edition) and built using Visual Studio 2010. When I deploy the website project to my local IIS server or the production IIS server hosted on a hosting service's VPS, the API Controller can be accessed via /api/notifications/, which is done via an AJAX call from a webpage. The problem is, on an identical setup on the Amazon EC2 instance, none of the API Controllers work, they all result in a 404 not found response. I checked that the same version of the .NET framework is installed everywhere, that IIS is running the same handler mappings, modules, ISAPI filters, Request Filtering, and ASP settings are all identical. Ran failed request tracing on the EC2 instance and got no asp related errors. Everything is up to date. I tried adding:

<modules runAllManagedModulesForAllRequests="true" />

and also tried adding:

<handlers>
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" 
         type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" 
         requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

To the appropriate places in the web.config file and still no api controllers. Normally, the website gets deployed to the "wwwroot" folder and everything else works, so I also tried deploying to a virtual directory by creating an application and accessing /Test/api/notifications/ still results in a 404 (while I can access the rest of the site at /Test/).

I tried re-registering the framework via this post: http://www.aheil.de/2012/11/05/fixing-asp-net-mvc-4-web-api-404/

I made sure that "Allow unlisted file name extensions" was checked in the IIS config.

Any ideas why this isn't working on the EC2 instance?

  • Is it an MVC application? Do you have the correct MVC framework installed? – Matt Houser Jan 3 '14 at 23:35
  • @MattHouser It is not an MVC application. It's built from a Visual Studio 2010 website project. The API Controller code is inside the App_Code directory. – Jon Lin Jan 4 '14 at 0:04
1

The problem was that .NET Framework 4.5 was installed on all the dev machines but not on the Amazon EC2 Windows Server 2008 R2 server. Installing .NET 4.5 apparently also updated old 4.0 assemblies (in particular, I suspect System.Net.Http and System.Web.Http), and because the webapp was built against the 4.5 versions of these 4.0 assemblies the Web API Controller wouldn't initialize when deployed on the EC2 server.

Solution: make sure that the framework assemblies are the same on the EC2 server as they are on the dev machines:

  1. Install .NET 4.5 on the EC2 server
  2. Uninstall .NET 4.5 on the dev machines.

Also a lot of useful information in this MSDN thread

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.