Saturday, August 1, 2015

ASP.NET Web REST API Settings

I created a new ASP.NET Web API REST Service and I deployed it on the IIS Server. It didn't work.

I made sure that the .NET framework is correct.

Finally I found this link.

http://stackoverflow.com/questions/15622720/net-web-api-404-file-or-directory-not-found

As per the recommendation here, I downloaded the ASP.NET MVC Setup from the following Microsoft Link and installed it on the IIS Server.

http://www.microsoft.com/en-us/download/details.aspx?id=30683

Then it started working.

After few days, I installed Visual Studio 2015 and removed Visual Studio 2013 from my laptop.

In Visual Studio 2015, I created a brand new ASP.NET Web API REST Service and published on the same server. Once again , my application stopped working. At the same time, the old application which I published using Visual Studio 2013 was still working.

Then I started to compare the "Web.Config" file and I realized that Visual Studio 2015 was missing this parameter (runAllManagedModulesForAllRequests).

<system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="FormsAuthentication" />
    </modules>
  </system.webServer>

After adding this settings in the Web.Config, then the HTTP REST services started to work.

Hope these tips will save you some time.

Cheers
Adam


 

No comments:

Post a Comment

All Blogs so far ...