Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Query and QueryString in asp.net

Can anyone tell me what is the difference between Query and QueryString in C# or Asp.Net.

like image 320
Radhe Sham Avatar asked Mar 23 '26 07:03

Radhe Sham


1 Answers

If you are working with ASP.NET Core, then:

  • Request.QueryString: Is the raw query string. for example, in http://a.com?name=vahid&lastname=farahmandian the Request.QueryString is ?name=vahid&lastname=farahmandian which is a raw string.

  • Request.Query: Is a query value collection parsed from Request.QueryString. for example in http://a.com?name=vahid&lastname=farahmandian, the Request.Query is a collection with two members:

Member 1: Key=name and Value=vahid

Member 2: Key=lastname and Value=farahmandian

Which both are parsed from Request.QueryString

Read More: Request.Query: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httprequest.query?view=aspnetcore-7.0#microsoft-aspnetcore-http-httprequest-query

Request.QueryString: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httprequest.querystring?view=aspnetcore-7.0

like image 133
Vahid Farahmandian Avatar answered Mar 24 '26 19:03

Vahid Farahmandian