title: ASP.Net MVC - Passing data between Views
body: <p>I'm currently trying to create an XML based website which has access to a feed URL. The XML feed is queried by adding url parameters to the current URL, and so I am using a form with GET method to add parameters to the URL. </p>
  
  <p>I currently have a property search form which will search for properties within the feed by adding xml parameters to the url like so:</p>
  
  <p><strong>/Sales/?minprice=300000&amp;maxprice=500000</strong></p>
  
  <p>This works perfectly and the correct results are shown to the user. However, if I was to use a filter form which filtered these properties by highest price for example, the feed parameters would be removed when the filter form is submitted. The new URL after the filter would be for example:</p>
  
  <p><strong>/Sales/?priceSort=descending</strong></p>
  
  <p>As you can see, the minprice and maxprice fields have been removed completely, leaving me with unwanted properties. </p>
  
  <p>Currently, to combat this I am using sessions to store the URLs for each page and then combining them to make 1 url. I understand that using sessions within MVC based applications isn't exactly recommended.</p>
  
  <p>So, I'm really just wondering if there is a better way to store the url's rather than using sessions?</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Thanks in advance.</p>
  
  <p>SOME CODE SNIPPETS OF THE SITE:</p>
  
  <p><strong>Model and ViewModel</strong></p>
  
  <pre><code>    public class ResultsViewModel 
  {
      public PropertyResult[] Property { get; set; } 
  }
  
  public class PropertyResult
  {
      public int Count { get; set; }
      public int Pid { get; set; }
      public int RentalPeriod { get; set; }
      public string Price { get; set; }
  
      public string Address { get; set; }
      public string NameNumber { get; set; }
      public string SA1 { get; set; }
      public string SA2 { get; set; }
      public string Town { get; set; }
      public string City { get; set; }
      public string County { get; set; }
      public string Postcode { get; set; }
  
      public string LocationCode { get; set; }
  
      public string PriceText { get; set; }
      public string Primary1 { get; set; }
      public string Secondary1 { get; set; }
      public string Secondary2 { get; set; }
      public string Description { get; set; }
  
      public string Period { get; set; }
  
      public int Bedrooms { get; set; }
      public int Receptions { get; set; }
      public int Bathrooms { get; set; }
      public int Garages { get; set; }
      public int Gardens { get; set; }
  
      public bool Featured { get; set; }
      public int Views { get; set; }
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>try
          {
              var xml = XElement.Load(resultsFeed);
  
              var query = (from props in xml.Descendants("property")
                           select new PropertyResult
                           {
                               // property id
                               Pid = Convert.ToInt32(props.Attribute("id").Value),
  
                               // Rooms Count
                               Bedrooms = Convert.ToInt32(props.Attribute("bedrooms").Value),
                               Receptions = Convert.ToInt32(props.Attribute("receptions").Value),
                               Bathrooms = Convert.ToInt32(props.Attribute("bathrooms").Value),
                               Gardens = Convert.ToInt32(props.Attribute("gardens").Value),
                               Garages = Convert.ToInt32(props.Attribute("garages").Value),
  
                               // 1 = sales prop, 4 = lettings prop
                               RentalPeriod = Convert.ToInt32(props.Attribute("rentalperiod").Value),
  
                               Period = props.Attribute("period").Value,
  
                               // address 
                               Address = props.Element("useAddress").Value,
                               NameNumber = props.Element("num").Value,
                               SA1 = props.Element("sa1").Value,
                               SA2 = props.Element("sa2").Value,
                               Town = props.Element("town").Value,
                               City = props.Element("city").Value,
                               County = props.Element("county").Value,
                               Postcode = props.Element("postcode").Value,
  
                               // location code
                               LocationCode = props.Element("locationcodes").Value,
                               Featured = Convert.ToBoolean(props.Attribute("featured").Value),
  
                               // description
                               Description = props.Element("summaryDescription").Value,
  
                               // price
                               Price = props.Attribute("price").Value,
                               PriceText = props.Element("pricetext").Value,
  
  
  
                               // images
                               Primary1 = "http://lb.dezrez.com/Imaging/PictureResizer.ASP?Position=1&amp;AgentId=" + eaid + "&amp;BranchId="+ bid + "&amp;width=1000&amp;Category=Primary&amp;PropertyId=",
                               Secondary1 = "http://www.dezrez.com/estate-agent-software/ImageResizeHandler.do?&amp;photoID=2&amp;AgentID=1239&amp;BranchID=1976&amp;Width=1000&amp;PropertyId=",
                               Secondary2 = "http://www.dezrez.com/estate-agent-software/ImageResizeHandler.do?&amp;photoID=3&amp;AgentID=1239&amp;BranchID=1976&amp;Width=1000&amp;PropertyId=",
                           }).ToArray();
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <p>I'm currently accessing each node like so:</p>
  
  <pre><code>@Model.Property[i].Gardens
  </code></pre>