-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
I have a Razor Pages application with the following markup in my _Layout.cshtml file.
<li class="nav-item dropdown">
<a class="nav-link text-dark dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Reports
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" asp-area="Reports" asp-page="/Invoice/Index">Invoices</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" asp-area="Reports" asp-page="/ProfitabilityByCustomer/Index">Profitability by Customer</a>
<a class="dropdown-item" asp-area="Reports" asp-page="/ProfitabilityByLocation/Index">Profitability by Location</a>
<a class="dropdown-item" asp-area="Reports" asp-page="/CostAudit/Index">Cost Audit</a>
<a class="dropdown-item" asp-area="Reports" asp-page="/ChangeLogs/Index">Change Logs</a>
</div>
</li>
Notice the last link (to /ChangeLogs/Index). This page has a page route (@page "{id?}").
This markup appeared to be rendering correctly. But then I manually navigated to /Reports/ChangeLogs/61, and the markup above rendered as:
<li class="nav-item dropdown">
<a class="nav-link text-dark dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Reports
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="/Reports/Invoice">Invoices</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/Reports/ProfitabilityByCustomer">Profitability by Customer</a>
<a class="dropdown-item" href="/Reports/ProfitabilityByLocation">Profitability by Location</a>
<a class="dropdown-item" href="/Reports/CostAudit">Cost Audit</a>
<a class="dropdown-item" href="/Reports/ChangeLogs/61">Change Logs</a>
</div>
</li>
Notice the route value of the current page was appended to that last link. Somehow, the fact that the current page is /Reports/ChangeLogs/61, is causing the link in the menu to render with this route value!
I can't explain this. And I need to stop it from happening.
Further technical details
- ASP.NET Core 3.1
- Visual Studio 16.6.4 (Windows)
.NET Core SDK (reflecting any global.json):
Version: 3.1.302
Commit: 41faccf259
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.302\
Host (useful for support):
Version: 3.1.6
Commit: 3acd9b0cd1
.NET Core SDKs installed:
3.1.302 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download