Reputation:
I am trying to make an anchor execute a controller method, which is not working for me. This is my anchor:
<div class="topNavigationBar">
<a href="default/GoToGames">Games</a>
</div>
My controller is called Default
and its ActionResult method which I want to execute is called GoToGames
:
public IActionResult GoToGames()
{
return View("/Views/Games.cshtml");
}
I tried this:
<a asp-controller="Default" asp-action="GoToGames">Apps</a>
Which just makes the anchor unclickable. How can I make the anchor route to the ActionResult?
Upvotes: 0
Views: 198
Reputation: 504
In the Views folder, create the file _ViewImports.cshtml
and add the below line:
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Upvotes: 1