dotnet / dotnet/aspnetcore

Tag helper for create link is not works when I use AddPageRoute

Open
#45,408 3 comments 0 reactions 0 assignees View on GitHub
area-mvc investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

I use Razor pages.
I want to defined 2 routes for a razor page, so I use AddPageRoute.
```
builder.Services.AddRazorPages()
.AddRazorPagesOptions(options =>
{
options.Conventions.AddPageRoute("/Product", "/product/code-{productCode1}");
options.Conventions.AddPageRoute("/Product", "/product/code-{productCode1}/code-{productCode2}");
});
```
```
public async Task OnGet(int productCode1, int productCode2)
{
return Page();
}
```
When I use second route for create link, everything is ok.
```
link
```
and result is:
```
https://localhost:1898/product/code-6/code-18
```
But if I want to use first route:
```
options.Conventions.AddPageRoute("/Product", "/product/code-{productCode1}");
```
```
link
```
The tag helper not works and the href of the ```a``` tag is empty.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two AddPageRoute configurations and the corresponding asp-page links in a Razor Pages application. Compare the generated href for the one-parameter route with the expected /product/code-6 URL; done means the tag helper generates that href while preserving the existing two-parameter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.