I been googling to find a way to read parameter value from URL but no success. In ASP.NET Webform we used to do Request.Querystring["name"] to get the value. How to do this in MVC3?
I need to access parameter in HtmlHelper class. Anyone please.
There is no clear answer on the internet for this. Strange...
I still use HttpContext.Current.Request.QueryString
in MVC3...
if (!Request.QueryString["ParameterName"].IsEmpty())
{
// Do something only if URL parameter "ParameterName" is not empty...
}
For example:
http://192.168.1.106:7777/Measurement?sort=FatPercentage&sortdir=DESC
if (!Request.QueryString["sort"].IsEmpty())
{
// sort=FatPercentage. It's not empty and this code block will be executed
}
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