How do I access the querystring
value in a View?
MVC framework automatically converts a query string to the action method parameters provided their names are matching. For example, the query string id in the following GET request would automatically be mapped to the Edit() action method's id parameter. This binding is case insensitive.
A Query String Collection is used to retrieve the variable values in the HTTP query string. If we want to transfer a large amount of data then we can't use the Request. QueryString. Query Strings are also generated by form submission or can be used by a user typing a query into the address bar of the browsers.
It is not a good design to access query 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. If you want to ignore this rule you could always do this in your view:
<%= Request["SomeParameter"] %>
But I would strongly discourage you from doing so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With