---
title: "How to read querystring values in ASP.NET Core?"  
description: "How to read querystring values in ASP.NET Core?"  
author: "Utpal Vishwas"  
published: 2023-07-06  
updated: 2023-07-07  
canonical: https://www.mindstick.com/forum/158979/how-to-read-querystring-values-in-asp-dot-net-core  
category: ".net core"  
tags: ["asp.net", "asp.net core", ".net core"]  
reading_time: 2 minutes  

---

# How to read querystring values in ASP.NET Core?

How to read [querystring](https://www.mindstick.com/interview/123/what-is-querystring-benefits-and-limitations-of-using-querystring) [values](https://www.mindstick.com/forum/327/sum-textbox-values) in [ASP.NET Core](https://www.mindstick.com/articles/12946/get-started-with-asp-dot-net-core-mvc-and-visual-studio)?

## Replies

### Reply by Aryan Kumar

There are a few ways to read query string values in [ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) Core.

- **Using the** `Request.QueryString` **property:** The `Request.QueryString` property is a dictionary that contains all of the query string parameters for the current request. You can access a query string parameter by using its name as the key. For example, to get the value of the `name` query string parameter, you would use the following code:

C#

```plaintext
var name = Request.QueryString["name"];
```

- **Using the** `IQueryCollection` **interface:** The `IQueryCollection` interface is an abstract interface that is implemented by the `QueryString` class. You can use the `IQueryCollection` interface to iterate through all of the query string parameters and to get the value of a specific query string parameter. For example, the following code will iterate through all of the query string parameters and print their values:

C#

```plaintext
foreach (var queryParam in Request.QueryString)
{
    Console.WriteLine(queryParam.Key + " = " + queryParam.Value);
}
```

- **Using the** `QueryParser` **class:** The `QueryParser` class is a class that can be used to parse query strings. You can use the `QueryParser` class to get a list of all of the query string parameters and their values. For example, the following code will get a list of all of the query string parameters and their values and then print them:

C#

```plaintext
var queryParser = new QueryParser(Request.QueryString);
var queryParamList = queryParser.GetQueryParameters();
foreach (var queryParam in queryParamList)
{
    Console.WriteLine(queryParam.Key + " = " + queryParam.Value);
}
```

Which method you use to read query string values in ASP.NET Core will depend on your specific needs. If you need to access a single query string parameter, then using the `Request.QueryString` property is the simplest way to do it. If you need to iterate through all of the query string parameters or if you need to get a list of all of the query string parameters and their values, then using the `IQueryCollection` interface or the `QueryParser` class is a better option.


---

Original Source: https://www.mindstick.com/forum/158979/how-to-read-querystring-values-in-asp-dot-net-core

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
