0

I am working on Console Application and, I am calling a web API from console application to put data onto the web API but when I am getting the data using GetAsync() method I am able to get the data and when I am putting the data also able to put data while the web API is not hosted on IIS

After hosting on IIS I got the status code 405 "Method not allowed"

I have also tried enabling cors inside web API config in a register()

config.EnableCors();

and

[EnableCors(origins: "*", headers: "*", methods: "*")]
public class ValuesController : ApiController

Any help will be Appreciated.

Thanks

Jay Prajapati
  • 362
  • 4
  • 26
  • I would suggest you restructure your question so it is understandable. What I gather your problem is: It works fine locally but when you put it on your IIS server it does not? – Trey Jul 12 '17 at 13:08
  • 1
    Possible duplicate of [How do I enable HTTP PUT and DELETE for ASP.NET MVC in IIS?](https://stackoverflow.com/questions/12440277/how-do-i-enable-http-put-and-delete-for-asp-net-mvc-in-iis) – mjwills Jul 12 '17 at 13:21
  • @mjwills he has mentioned that it is the console application – aayushi Jul 13 '17 at 05:28
  • The Web API is being hosted in IIS. He would get this issue if he posted from a console app, or Postman, or a web browser or whatever. Because the issue is not with the console app. **It is with the server side (IIS).** – mjwills Jul 13 '17 at 08:21
  • @mjwills Thanks for your reply but I don't know why the Put method was not worked for me so i just used PostAsJsonAsync() and it works. – Jay Prajapati Jul 13 '17 at 11:04
  • Did you read the link I provided? – mjwills Jul 13 '17 at 12:25

1 Answers1

1

I was putting the data onto Web API using PutJsonAsAsync(), but It doesn't work with PutJsonAsAsync() I don't know why but when I used PostAsJsonAsync() it works for me.

thanks

Jay Prajapati
  • 362
  • 4
  • 26