The asked for reresource does not support http approach 'GET'

Jun 13, 2015 06:51 AM|vuyiswamb|LINK
Good Day Alli have actually a web api through a controller favor this

public class RegistrationController : ApiController public int Get(Registration model) attempt GetMyContact.Services.Database.Database db = new Database.Database(); db.RegisterUser(model); var response = Request.CreateResponse(HttpStatusCode.Created, string.Empty); string uri = Url.Link("DefaultApi", new id = version.USER_ID ); response.Headers.Location = new Uri(uri); return design.USER_ID; catch(Exception ex) HttpStatusCode statusCode = HttpStatusCode.BadRequest; var errResponse = Repursuit.CreateResponse(statusCode, ex.Message); throw new HttpResponseException(errResponse); and the config is like this

config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/controller/id", defaults: brand-new id = RouteParameter.Optional );and also i am trial and error it making use of the following URL just to watch if i will certainly hit that breakallude http://localhost:39194/api/Registrationbut i get the adhering to error on the browser

The asked for resource does not support http technique "GET".Thanks


mostafasydne...

You are watching: The requested resource does not support http method get

Contributor


Re: The requested reresource does not assistance http strategy 'GET'

Jun 13, 2015 07:29 AM|mostafasydney|LINK
You have the right to have actually a look comparable concerns in the forum.

http://carolannpeacock.com/t/2001781.carolannpeacock.comx?The+requested+resource+does+not+support+http+method+DELETE+

http://carolannpeacock.com/t/2006277.carolannpeacock.comx?The+requested+resource+does+not+support+the+method+http+PUT+

Also have a look at: http://solvedstack.com/questions/carolannpeacock.com-net-web-api-the-requested-resource-does-not-support-http-method-get

Regards,

Mostafa


Best Regards,MostafaIf this write-up helps you to fix your difficulty, do not forgain to "Mark as Answer"
santhoshje

Contributor


Re: The requested reresource does not assistance http technique 'GET'

Jun 13, 2015 05:26 PM|santhoshje|LINK
Please use Article technique in this situation and also embed model object in research body making use of .Net code or JQuery.

See more: Intel 7200U Vs Amd A10-9600P Vs I5-7200U, Intel Core I5

public course RegistrationController : ApiController public int Post(Registration model) /* Add your logic here*/ Use complying with code to call Internet Api

using (var client = brand-new HttpClient()) client.BaseAddress = brand-new Uri("http://localhost:58745/"); var response = client.PostAsJsonAsync("api/Registration",model).Result; if (response.IsSuccessStatusCode) string responseString = response.Content.ReadAsStringAsync().Result;


Qigang Zhong

Member


Re: The asked for reresource does not support http strategy 'GET'

Jun 15, 2015 08:40 AM|Qigang Zhong|LINK

vuyiswamb public int Get(Registration model) {


vuyiswamb,

Some of the users met this problem bereason they use the qualities inSystem.Net.MVC nameroom, however your"s are correct, by default it"ll work-related fine via your code. However before there"s still another situation which can cause the "not assistance http method" problem. That is the handler settings in Net.config file or the project and the IIS, or possibly the machine.config file. Please see this article for troubleshoot this trouble in the config file:

Troubleshooting HTTP 405 Errors after Publishing Web API 2 Applications

If you still can not deal with this problem, please upload a sample job in OneDrive and also share the file link right here so that we deserve to redevelop your trouble and also give you additionally assist. Thanks.