KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This error is very common, and I tried all of the solutions and non of them worked. I have disabled WebDAV publishing in control panel and added this to my web config file: <handlers> <remove name="WebDAV"/> </handlers> <modules runAllManagedModulesForAllRequests="true"> <remove name="WebDAVModule"/> </modules> The error still persists. This is the controller: static readonly IProductRepository repository = new ProductRepository(); public Product Put(Product p) { return repository.Add(p); } Method implementation: public Product Add(Product item) { if (item == null) { throw new ArgumentNullException("item"); } item.Id = _nextId++; products.Add(item); return item; } And this is where the exception is thrown: client.BaseAddress = new Uri("http://localhost:5106/"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.PostAsJsonAsync("api/products", product);//405 exception Any suggestions?
Tags (comma-separated)
Save Edits
Cancel