Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link generation improvements #38121

Open
javiercn opened this issue Nov 5, 2021 · 7 comments
Open

Link generation improvements #38121

javiercn opened this issue Nov 5, 2021 · 7 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing
Milestone

Comments

@javiercn
Copy link
Member

javiercn commented Nov 5, 2021

We have a relatively big backlog of issues with regards to link generation changes that happened between traditional routing and endpoint routing. One of the biggest changes is in the way we deal with ambient values. Changes in endpoint routing can cause some abnormal behaviors when generating links.

@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing jcn-p0 labels Nov 5, 2021
@javiercn javiercn added this to the .NET 7 Planning milestone Nov 5, 2021
@mkArtakMSFT mkArtakMSFT added Priority:1 Work that is critical for the release, but we could probably ship without triaged labels Nov 11, 2021
@mkArtakMSFT
Copy link
Member

@javiercn it seems this one never got broken into individual issues prioritized. Costing the umbrella as L for now, but prioritizing the items internally could help/.

@yecril71pl
Copy link
Contributor

yecril71pl commented Jan 29, 2022

Consider the following code:

services .AddRazorPages(options => options .Conventions .AddPageRoute ("/A/B", "/A/C")); 

Assume that the page /A/B exists and the page /A/C does not.
in page /A/D:

<a asp-page="C" asp-route-id="0" >&hellip;</a >

Then the result is

<a href="/A/D?id=0" >&hellip;</a >

It seems the only work-around is to make C.cshtml.cs redirect to B.

@valeriob
Copy link

valeriob commented Feb 9, 2022

Shall i suggest to track this issue too ? #31476

@Alerinos
Copy link

I think it is also worth being interested in.
Multi routing is sorely lacking

#37485
#39719

@Alerinos
Copy link

Alerinos commented Mar 17, 2022

When it comes to generating links, I would recommend using the page class. Example:

Counter.razor 
@page "/Counter"

<link href="@Pages.Counter">Counter</link>

output:
<a href="/Counter">Counter</a>

This causes the content of @page to be inserted in place of href

For this you can create a provider that adds other constants, e.g. culture.

@valeriob
Copy link

valeriob commented Jun 27, 2022

Are you sure link generation can't be fixed on net7 ? So much energy is spent on minimal api and blarzors instead, not much on mvc I'm afraid :(
I'v seen this movie on net5, then net6, now net7....

@nfplee
Copy link

nfplee commented Jun 28, 2022

@valeriob I echo your thoughts about MVC. So much wasted energy is being spent on improvements to minimal API just to mimic what you can already do in MVC. As for Blazor, how about showing some love for people that use alternatives such as htmx and/or petite-vue/alpine.js which compliment MVC and razor pages.

The link generation improvements would benefit everyone. The specific issue I'm concerned with is #16960 which was a regression introduced with endpoint routing and has still not been addressed.

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Nov 1, 2022
@mkArtakMSFT mkArtakMSFT removed the Priority:1 Work that is critical for the release, but we could probably ship without label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing
Projects
None yet
Development

No branches or pull requests