On my site I have a page on /Home/Index
This is the index page in my HomeController.
To reach this page I have the link:
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
I want to add the same link for a different page, but this page is located on /Products/Food/Index. I tried the following:
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Products/Food" asp-action="Index">Food</a>
</li>
But this results in /Products/Food/Index
in the URL bar.
What can I do to reach this page using the way of referencing pages?
CodePudding user response:
Just use
<a class="nav-link text-dark" href="/Products/Food/Index">Food</a>
It is basically same with using anchor tag with asp-*, those are tag helpers
CodePudding user response:
May be you need to change the folder structure like create Area "Products" in that Products add Controller "FoodController.cs" then add a view "Index".
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Products" asp-controller="Food" asp-action="Index">Food</a>
</li>