0
votes

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

1
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
@mjwills he has mentioned that it is the console application - aayushi
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
@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

1 Answers

1
votes

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