Let's say I have the following Razor file _Layout.cshtml. How do I write the commented conditions when using ASP.NET Core 3+ and Razor Pages.
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" asp-page="/Index">Index</a>
</li>
@* If route starts with /a/, for example http://localhost/a/1.html and http://localhost/a/2/1.html *@
<li class="nav-item">
<a class="nav-link" asp-page="/a/Index">A</a>
</li>
@* If route starts with /b/, for example http://localhost/b/1.html and http://localhost/b/2/1.html *@
<li class="nav-item">
<a class="nav-link" asp-page="/b/Index">B</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-page="/b/1/Index">B other</a>
</li>
</ul>
ViewStateand show / hide elements based on that. See stackoverflow.com/a/57040167/12730491 (here they change the whole Layout file, but it should work for single elements too). - rm-code