Click here to Skip to main content
15,393,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to do an ajax POST in an mvc 5.0 WebApi web application. Can do a GET just fine but when I try to update a field using GET that has a large amount of data I get the 405 error.

Am I on the right track or am I looking in the wrong direction?

Also is there any good/simple web.config options reference?

Thanks,
Mike

What I have tried:

I've tried many different options in the web.config file pertaining to WebDAV, including completely removing it; 1) In the "Turn Windows features on or off", removing it in web.config file and configuring it. This is what I currently have in my web.config file;
<system.web>
  <authentication mode="None" />
  <compilation debug="true" targetFramework="4.5.1" />
  <httpRuntime targetFramework="4.5.1" />
  <trust level="Full" />
</system.web>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
    <remove name="FormsAuthentication" />
  </modules>
  <handlers>
    <remove name="WebDAV" />
    <add name="WebDAV" path="*" verb="*" modules="WebDAVModule" resourceType="Unspecified" requireAccess="None" />
  </handlers>
</system.webServer>
Posted
Updated 6-Feb-17 22:32pm
Comments
Richard Deeming 2-Feb-17 14:53pm
   
"... update a field using GET ..."

GET requests shouldn't update anything. :)
Mike Hankey 2-Feb-17 15:01pm
   
I realize that but when POST, PUT won't work and GET does I have to use it until I can solve this problem. The GET will work but have a cap, I believe of 2K or so, so I have to save in smaller chunks.

Please check below code api example for 405 example hope its help you.
troubleshooting-http-405-errors-after-publishing-web-api-applications.
   
Update just an FYI for those in a like position, found a solution after much gnashing of teeth;

Add to web.config;

<modules runAllManagedModulesForAllRequests="false">
  <remove name="WebDAVModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
  <remove name="WebDAV" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

and even after that it did not work so after more research I found that you can only pass one parameter in an ajax post. After I changed that everything worked great.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900