Tuesday 15 July 2014

asp.net mvc - MVC AttributeRouting With GET - Returning 405 - Method Not Allowed -


I'm just working on a new controlling method and I'm a little confused why I'm seeing 405.

I have already defined the methods responsible for many GETs on my APIs and as expected, all functions work fine for example:

  [GET ("Entries / {Page}"), JSN Express Filter] Public HTTP Responses GetEntries (int page)   

So far my new method is defined like this:

  [GET ("search / {searchTerm} / {page}"), JsonExceptionFilter] Public HttpResponseMessage Search (string searcharm, int pe )   

A 405 is returning

If I go to the RootsX URL on the API, then I can see an entry in the table like this:

  GET, head, option user / search / {searchTerm} / {page}   

All of this looks right. On the client side, I am using the same approach on both requests using a HTTP client:

  var response = httpclient.GetAsync (ApiRootUrl + "users / search /" + SearchTerm + "/" + Page) .Result;   

The trend of meeting Fiddler also gives 405.

The request in response also looks correct by looking at the message:

  "{method: GET, RequestUri: 'http: // localhost: 51258 / user / search / jam / 0 '"  

Completely stumped on it.

And what if I might try to put some light on the wrong?

You will need to decorate the search Another feature called System.Web.Http.HttpGetAttribute Work with due to its reasons, you can see your answer in the answer given below:



No comments:

Post a Comment