I added a controller named Welcome to the sample project created by Visual Studio. This sample project comes with Home and Home/Privacy links. I modified the file _Layout.cshtml to add the next link to the view Welcome/Index.cshtml as follows:
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Welcome">Welcome</a>
</li>
</ul>
When I execute the project and I begin to navigate in the following order over the links:
- Home
- Welcome (fine)
- Home/Privacy
4. Welcome/Privacy (wrong)
The problem is in the 4. step, the /Privacy remains instead of left /Welcome alone.
How can I solve this?
Cristian Jacob Jimenez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.