I am using Visual Studio 2017..... when I created the project, an AccountController was created with this action:
// POST api/Account/Logout
[Route("Logout")]
public IHttpActionResult Logout()
{
Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType);
return Ok();
}
On the other hand, this route was created by default:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
I need to do a very simple thing. How can I get the Logout URL in a view?
I tried
@Url.Action("Logout", "Account", new { httproute = "DefaultApi" })
But it did not work since DefaultApi does not contain the action, causing the action to be added as a query string parameter.
If I don't use httproute property, the URL is built but without the "api" part causing the framework to not find it.
I have even tried
@Url.RouteUrl("DefaultApi", new { httproute = "Logout", controller = "Account" })">
with no success either.