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

[Parameter] is necessary also for [SupplyParameterFromQuery] #31554

Closed
JZO001 opened this issue Jan 24, 2024 · 6 comments · Fixed by #31569
Closed

[Parameter] is necessary also for [SupplyParameterFromQuery] #31554

JZO001 opened this issue Jan 24, 2024 · 6 comments · Fixed by #31569
Assignees
Labels
aspnet-core/svc blazor/subsvc Blazor doc-enhancement Pri1 High priority, do before Pri2 and Pri3 Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@JZO001
Copy link

JZO001 commented Jan 24, 2024

Description

In the section "Query strings", information is missing. "SupplyParameterFromQuery" does not stand alone, [Parameter] attribute is also necessary. Without it, the parameter from the query will not be processed.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/fundamentals/routing.md

Document ID

b6cb2574-6326-a40d-0b6c-d1661328e828

Article author

@guardrex

Copy link
Contributor

🎉🥳 Happy New Year! 💃🕺

A green dinosaur 🦖 will be along shortly to assist. Stand-by ........

@guardrex
Copy link
Collaborator

guardrex commented Jan 24, 2024

Not strictly necessary AFAIK. Let's ping @MackinnonBuck ... Should the guidance add a line that says something like ...

If the query string parameter must also serve as a [component parameter](xref:blazor/components/index#component-parameters), also include the [`[Parameter]` attribute](xref:Microsoft.AspNetCore.Components.ParameterAttribute):

... and then I can add a little example like ...

[Parameter]
[SupplyParameterFromQuery]
public string? Filter { get; set; }

@guardrex guardrex added Pri1 High priority, do before Pri2 and Pri3 doc-enhancement labels Jan 24, 2024
@JZO001
Copy link
Author

JZO001 commented Jan 24, 2024

On my side - using .NET 7.0.15 - on a normal page (not a component), I used the "SupplyParameterFromQuery" to get an int? parameter from query. It does not work, and I had to google for a while to figure out the reason. Than I spotted out, in other examples, there is the "Parameter" also. After added it to my property into my page, than it started to work fine.

@guardrex
Copy link
Collaborator

normal page (not a component)

I don't understand. This API is only for Razor components AFAIK.

Mackinnon, one of our TOP product unit engineers will be along in a bit to take a look at this and advise further. I'll email him, too, to make sure he gets the ping. He usually responds by EOD unless he's OOF. Stand-by .......................

@MackinnonBuck
Copy link
Member

On my side - using .NET 7.0.15

Ah, yep. Before .NET 8, both [Parameter] and [SupplyParameterFromQuery] were required in order for a parameter's value to be supplied via query. We removed this requirement in .NET 8.

AFAICT, the docs are correct - the .NET 8 page omits the [Parameter] attribute, and the .NET 7 page includes it.

@guardrex, do you think it would make sense to add a note in the .NET 8 version of the docs to clarify that when using a version earlier than .NET 8, the [Parameter] attribute must be used in conjunction with the [SupplyParameterFromQuery] attribute? Or do we try to avoid including info about previous .NET versions?

@guardrex
Copy link
Collaborator

guardrex commented Jan 25, 2024

add a note in the .NET 8 version of the docs ... Or do we try to avoid including info about previous .NET versions?

Yes ... that's right about not adding it to the reference doc. I'll place a section on this in the Migration article. We mostly avoid doing it in the reference docs because they would eventually be filled with thousands of little "this changed in version X" remarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspnet-core/svc blazor/subsvc Blazor doc-enhancement Pri1 High priority, do before Pri2 and Pri3 Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants