405 Methode nicht erlaubt Web API

Dieser Fehler ist sehr Häufig, und ich habe versucht, alle Lösungen und nicht von Ihnen arbeitete. Ich habe deaktiviert WebDAV-publishing " im control panel Hinzugefügt und diese auf meine web-config-Datei:

  <handlers>
  <remove name="WebDAV"/>
  </handlers>
  <modules runAllManagedModulesForAllRequests="true">
  <remove name="WebDAVModule"/>
  </modules>

Der Fehler weiterhin besteht. Dies ist die Steuerung:

   static readonly IProductRepository repository = new ProductRepository();

    public Product Put(Product p)
    {
        return repository.Add(p);
    }

Methode Durchführung:

 public Product Add(Product item)
    {
        if (item == null)
        {
            throw new ArgumentNullException("item");
        }
        item.Id = _nextId++;
        products.Add(item);
        return item;
    }

Und das ist, wo die exception geworfen wird:

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

Irgendwelche Vorschläge?

InformationsquelleAutor der Frage Xardas | 2013-03-30

Schreibe einen Kommentar