4

I have created a simple WebAPI using .Net Core 2.2. While I use POSTMAN to hit the action method with PUT HttpVerb, I get 405 - Method not allowed message. While I checked for this online, the suggestion was to remove the WebDAV module from the Web.config. But in the .Net Core WebAPI, there is launchSettings.json and appsettings.json for the configuration.

Kindly help me as to how to set the setting in either of the aforementioned config files to remove the WebDAV module.

I'm new to .Net Core.

I tried to create a Web.Config and used the below code to remove the WebDAV module, but no luck

<system.webServer>
  <modules runAllManagedModulesForAllRequests="false">
    <remove name="WebDAVModule" />
  </modules>
</system.webServer>

I haven't done this is WebAPI without using .Net Core. The request from POSTMAN is expected to hit the PUT method.

Kindly help.

How to convert this setting to JSON format for appSettings.json

  • Do you host the application on IIS ? Try [this](https://ignas.me/tech/405-method-not-allowed-iis/) and [this](https://stackoverflow.com/a/50624155/5751404) . – Nan Yu Sep 25 '19 at 02:12
  • Thanks Nan Yu. I use IIS express to run the Web API locally. I use POSTMAN to test the locally run Web API. Kindly help on this scenario. – user2636730 Sep 25 '19 at 03:57
  • Show you related codes , i remember iis express by default support put verbs – Nan Yu Sep 25 '19 at 05:19
  • @NanYu here is the code `// PUT: api/Employee/5 [HttpPut("{id}")] public Employee Put(int id, [FromBody] Employee employee) { var empList = GetStdEmployeeList(); empList.Where(iter => iter.Id == id).FirstOrDefault().Name = employee.Name; empList.Where(iter => iter.Id == id).FirstOrDefault().Salary = employee.Salary; return empList.Where(iter => iter.Id == id).FirstOrDefault(); }` – user2636730 Sep 25 '19 at 08:57
  • Do you need the Startup.cs code too? – user2636730 Sep 25 '19 at 08:59
  • Exact same issue... did you ever find a solution? – Anthony Griggs Mar 05 '21 at 20:01

0 Answers0