filmov
tv
Blazor (ASP.NET Core) - Working With Query String | Query Parameter

Показать описание
The query string is part of the URL that contains values for specific parameters. In other words, it is a collection of key-value pairs encoded into the URL. The most common use of the query string is to pass data between two routes as Http is stateless protocol. Using “?”, you can separate the query string from the URL. The first part of the query string is key, and each key-value is separated by a “=”. If there is more than one key-value pair you need to define into a URL, then "&" is used to separate them.
The NavigationManager service is the default service in Blazor that provides an abstraction for querying and managing URI navigation. The Microsoft.AspNetCore.WebUtilities library provides helpesr (QueryHelpers class) to deal with query string. The QueryHelpers class has method "ParseQuery" that returns Dictionary and the returned dictionary contains all query strings in the URL.
In the following video , I am going to update the counter page that comes with default template to look at the inital count value from query string. I have given url "/counter?initialCount=20", so the counter starts from 20.
Passing parameter value as query string when redirecting
============================================
The Microsoft.AspNetCore.WebUtilities.QueryHelpers has a method "AddQueryString" that appends your key-value pair as a query string in to your URL. You can navigate to another component by using NavigationManager.NavigateTo method.
In the following example, I have added firstname and lastname in query string and redirected to another Blazor component.
In this video , I have added firstname and lastname in query string and redirected to another Blazor component.
query string parameters
blazor parameters
blazor parameter change
blazor tutorial
blazor train
blazor c#
blazor server
blazor .net 5
query string parameters
blazor passing parameter to component
blazor pass parameter onclick
blazor pass string parameter onclick
The NavigationManager service is the default service in Blazor that provides an abstraction for querying and managing URI navigation. The Microsoft.AspNetCore.WebUtilities library provides helpesr (QueryHelpers class) to deal with query string. The QueryHelpers class has method "ParseQuery" that returns Dictionary and the returned dictionary contains all query strings in the URL.
In the following video , I am going to update the counter page that comes with default template to look at the inital count value from query string. I have given url "/counter?initialCount=20", so the counter starts from 20.
Passing parameter value as query string when redirecting
============================================
The Microsoft.AspNetCore.WebUtilities.QueryHelpers has a method "AddQueryString" that appends your key-value pair as a query string in to your URL. You can navigate to another component by using NavigationManager.NavigateTo method.
In the following example, I have added firstname and lastname in query string and redirected to another Blazor component.
In this video , I have added firstname and lastname in query string and redirected to another Blazor component.
query string parameters
blazor parameters
blazor parameter change
blazor tutorial
blazor train
blazor c#
blazor server
blazor .net 5
query string parameters
blazor passing parameter to component
blazor pass parameter onclick
blazor pass string parameter onclick