AddRazorPages/MapRazorPages breaks generated link by asp-route-* tag helpers to MVC controller route. #25299
Labels
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
feature-routing
Needs: Attention 👋
This issue needs the attention of a contributor, typically because the OP has provided an update.
Describe the bug
I have scaffolded default identity pages into my MVC project, so I have a mix of razor pages and MVC views. However,
AddRazorPages
andMapRazorPages
are breaking one of my links generated by the asp-route-* tag helpers to one of my controller action methods.I have an action method that looks like the following:
When I generate the link in my view (without AddRazorPages/MapRazorPages), the link is generated correctly. For example, the following will generate the correct url as
symbols/aapl/apple-inc/news?page=2&perPage=20
.However, that same code with AddRazorPages/MapRazorPages in Startup.cs breaks the way that link is generated, and is rendered incorrectly as the following:
symbols/news?symbol=aapl&slug=aapl-inc&page=11&perPage=5
. Thesymbol
andslug
parameters are incorrectly rendered as part of the query, when they should be part of the route.To Reproduce
Link to repo to reproduce error: https://github.com/marlongerson/IncorrectRouting.
Step 1. With lines 28 and 57 in startup.cs commented out: Run the project. From home page, click on "Go to apple news", and notice that the pagination links are correct.
Step 2. Uncomment lines 28 and 57. Run the project. From home page, click on "Go to apple news", and notice that the pagination links break with AddRazorPages and MapRazorPages.
Exceptions (if any)
Further technical details
dotnet --info
Output of
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.400
Commit: 035fb2aa2f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.400\
Host (useful for support):
Version: 3.1.6
Commit: 3acd9b0cd1
.NET Core SDKs installed:
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.700 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
3.0.100-preview7-012821 [C:\Program Files\dotnet\sdk]
3.0.103 [C:\Program Files\dotnet\sdk]
3.1.100 [C:\Program Files\dotnet\sdk]
3.1.400 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotne
t\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.20 [C:\Program Files\dotne
t\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotne
t\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.20 [C:\Program Files\dotne
t\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Pro
gram Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet
\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [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.8 [C:\Program Files\dotnet\sh
ared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\sh
ared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\s
hared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.20 [C:\Program Files\dotnet\s
hared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\sh
ared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Progr
am Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\sh
ared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\sh
ared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\sh
ared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C
:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.Ap
p]
Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\do
tnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\do
tnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\do
tnet\shared\Microsoft.WindowsDesktop.App]
The text was updated successfully, but these errors were encountered: