Method Not Allowed alert when accessing Web.API methods

Posted by Sheonarayan under Error and Solution on 6/11/2014 | Points: 10 | Views : 1654 | Status : [Administrator] | Replies : 0


I was getting "Method Not Allowed" or "No conversation ....." alert message when trying to access the Web API method declared in the ASP.NET MVC Controller.


The solution of the problem is change in two places.

1. Make sure your API method attribute is [HttpGet]
public IQueryable<PersonalDetails> Search(string id)
var data = db.PersonalDetails.Where(p => p.FirstName.Contains(id));
return data;

2. Replace your System.webServer configuration to below in your root's web.config file


<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />

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

<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" />-->

This should solve the error.

Sheo Narayan


(No response found.)

Login to post response