Im building a simple api with asp.netcore 1.1 and trying to create hypermedia links. I have looked at
WebAPI Url.Link() returning NULL
and a couple of similars, but none of those were of help.
my controller is
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/organizers")]
public class OrganizersController : Controller
{
[HttpGet, Route("{id:int}", Name = "get-organizers")]
public IActionResult Get(int id)
{
try
{
var uri = Url.Link("default", new {id=2});
var uri2 = Url.RouteUrl("default", new { controller = "Organizers", action = "get-organizers", id = 1 });
(...)
}
(...)
}
My startup looks like
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
//serilog
loggerFactory.AddSerilog();
app.UseMvc(opt=>opt.MapRoute("default", "api/v{version:apiVersion}/{controller}/{action}/{id:int?}"));
appLifetime.ApplicationStopped.Register(() => ApplicationContainer.Dispose());
}
i have tried many permutations of the possible parameters including removing action, api, version, etc. still, i get null for both urls.