c# - Web API POST - 404 Not Found -


In my VS2013 web application, I have many controllers in this way:

  [root ("test / {param1}")] Public Bull Test (Int 32 Parama 1) {return true; }  

I call the law from my client:

  feedback = wait for the client. GetAsync ("TestCtrlClass / Test / 1");  

And all works well .

Now, I need to pass an object in ways, so I put it:

  [http post] [root ("Test 2 / IIT") ")] Public Child Test 2 ([BOBD] Classname Item) {returns correct; }  

I invoke the method from my client:

  HTTP client client = new HTTP client (); Client.BaseAddress = ServerUri; Client.DefaultRequestHeaders.Accept.Add (New MediaTypeWithQualityHeaderValue ("App / Jason")); MediaTypeFormatter jsonFormatter = New JsonMediaTypeFormatter (); Hpccent material = new object sitentant & lt; Classname & gt; (Object, JasonFormer); Response = wait client.PostAsync ("TestCtrlClass / Test2", content);  

And I can not find 404 found .

This is my root configuration:

  route IgnoreRoute ("{} resource .axd / {* pathInfo}"); Routes.MapMvcAttributeRoutes ();  

Why?

Thank you.

Note that you are sending a post request with parameters in the body. This means that the URL you are posting on TestCtrlClass / Test2 , not TestCtrlClass / Test2 / anything_here . Your attribute should be:

  [http post] [root ("test2")] public child test 2 ([bobeda] classname item)  

I also believe [fromBody] is not required here.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -