title: Get Query String Value in ASP.NET MVC Function
body: <p>I have an ASP.NET MVC app. My views use Razor. At the top of my CSHTML file, I have the following:</p>
  
  <pre><code>@functions
  {
      public static HtmlString IsSelectedCss(string name)
      {
          string selected = ""; // Need to get value of "t" from query string
  
          HtmlString attribute = new HtmlString("");
          if (selectedTab.Equals(name, StringComparison.InvariantCultureIgnoreCase))
          {
            attribute = new HtmlString("class=\"active\"");
          }                
          return attribute;
      }
  }
  </code></pre>
  
  <p>I need this function to examine the query string. Specifically, I need to get the value of the "t" query string parameter. My challenge is, I cannot seem to figure out how to get access to the QueryString in this function.</p>
  
  <p>How do I get the value of a query string parameter in a Razor function?</p>
  
  <p>Thanks!</p>