Give it back. Use VS to create a new controller. Make sure it's called someController, where some is the name of your controller, it should end in "Controller". Make sure your class inherits ApiController ...
public class someController : ApiController { [Route("api/test/{name}"), HttpGet] public string Router(string name) { return "Your name is: " + name; } }
Also add this to your global.asax file.
protected void Application_Start(object sender, EventArgs e) { GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
In the above example, the api route expects an HttpGet, you can also use HttpPost and use FormDataCollection to get the form data. Note how you can parameterize your APIs with {someparameter}
The above is quite simple, and the API controller can serialize most objects that implement serialization. If you can not use NewtonSoft or something like that.
source share