title: Saving values server side vs. using Sessions and Request.QueryString in ASP.net
body: <p>I'm making a simple asp.net app that displays data which can be filtered based on a few different parameters.  As such, the different filters that are currently selected need to be saved somewhere.  I'm fairly new to .NET, and am wondering the best way to save this information.  I noticed a coworker used Request.QueryString in conjunction with the Sessions dictionary. Something like this on page load:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e) 
  {
      if (Request.QueryString["Category"] != null &amp;&amp;
          Request.QueryString["Value"] != null)
      {
          string Category = Request.QueryString["Category"];
          string CategoryValue = Request.QueryString["Value"];
  
          // selectedFacets is the server side dictionary
          selectedFacets.Add(Category, CategoryValue);                    
      }
   }
  </code></pre>
  
  <p>The QueryString here is changed when the user presses a button on the webpage, updating the URL.</p>
  
  <p>My question is why even bother with the QueryString at all when all we're using it for is saving a value server side anyway?  Wouldn't just making the button an asp controller be easier, something like:</p>
  
  <pre><code>protected void exampleCatexampleVal_Button_onClick(object sender, EventArgs e) 
  {
       selectedFacets.Add(exampleCat, exampleVal);
  }
  </code></pre>
  
  <p>Similar business goes on the with the Sessions dictionary: it's just used to save a bunch of values to variables on the server, so why use it in the first place?  I'm sure there's a good reason, but right now they just seems overly complicated for what they do.  Thank you!</p>