---
title: "how to access query string value in ASP.Net MVC View"  
description: "how to access query string value in ASP.Net MVC View"  
author: "Sachin Singh"  
published: 2016-03-14  
updated: 2016-03-14  
canonical: https://www.mindstick.com/forum/34054/how-to-access-query-string-value-in-asp-dot-net-mvc-view  
category: "asp.net"  
tags: ["c#", "asp.net", "asp.net mvc", "html5", "view", "css"]  
reading_time: 1 minute  

---

# how to access query string value in ASP.Net MVC View

Hi Everyone,\
how to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) [query string](https://www.mindstick.com/articles/512/query-string-in-asp-dot-net) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) in [ASP.Net MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) View, Can [anyone give me](https://answers.mindstick.com/qa/41194/can-anyone-give-me-some-high-and-low-points-of-each-of-the-four-first-presidential-administrations) a solution.\
\
Thank you.

## Replies

### Reply by Anupam Mishra

Hi Sachin,\
**This is not a good pattern to access [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver) parameters in a view**. The view should use the model provided by the controller. So the controller reads query parameters and passes them to the view. For accessing query [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) to the controller to view then you can set that value to a property in your **ViewBag**. The **ViewBag** property can then be read in from your view.You can access Request variable in your view.\
**In Controller:** \

```
ViewBag.Val = Request.QueryString["Value"];
```

\
**In View:****\**

```
@if(ViewBag.Val == "......"){ ... }
```


---

Original Source: https://www.mindstick.com/forum/34054/how-to-access-query-string-value-in-asp-dot-net-mvc-view

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
