User360451555 posted
Hi, i cant seem to figure out what should be the route defined to reach my post method in a self-hosting website. It's running .Net Standard and eventually it will run as a windows service.
Here is how i have tried to structure the routing table
public static void Main(string[] args)
{
var config = new HttpSelfHostConfiguration(new Uri("http://localhost:43634"));
config.Routes.MapHttpRoute("API Default", "api/{controller}/{id}", new { id = RouteParameter.Optional });
InitPrintEngine();
using (HttpSelfHostServer server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
Console.WriteLine("Press Enter to quit.");
Console.ReadLine();
}
}
[Route("[api/controller]")]
public class LabelController : ApiController
{
[System.Web.Mvc.HttpGet]
public IEnumerable<string> Get()
{
return new[] {"Label1", "Label2"};
}
[System.Web.Mvc.HttpPost, Route("label/labelvariables")]
public async Task<HttpResponseMessage> PostFile(HttpPostedFile labelFile)
{
}
}
I've omitted the details of the PostFile method to have it as simple as possible. I cant reach the method though through postman.
This is how am trying to invoke the method
http://localhost:43634/api/Label/labelvariables/labelFile