Retrieving parameters from the query string in the URL in .Net

23 Jul 2013 .Net, C#, Filters, MVC No Comments

Here is a nice easy way to get the individual parameter values from the URL, returning either a NameValueCollection (System.Collections.Specialized.NameValueCollection HttpRequestBase.QueryString) of all parameters in the query string, or a string value of a particular named parameter.

var parameters = HttpContext.Request.QueryString;
var parameters = HttpContext.Current.Request.QueryString;
public class MyAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var

Continue reading →