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.
I currently have a property search form which will search for properties within the feed by adding xml parameters to the url like so:
/Sales/?minprice=300000&maxprice=500000
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:
/Sales/?priceSort=descending
As you can see, the minprice and maxprice fields have been removed completely, leaving me with unwanted properties.
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.
So, I'm really just wondering if there is a better way to store the url's rather than using sessions?
Any help would be much appreciated.
Thanks in advance.
SOME CODE SNIPPETS OF THE SITE:
Model and ViewModel
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; }
}
Controller
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&AgentId=" + eaid + "&BranchId="+ bid + "&width=1000&Category=Primary&PropertyId=",
Secondary1 = "http://www.dezrez.com/estate-agent-software/ImageResizeHandler.do?&photoID=2&AgentID=1239&BranchID=1976&Width=1000&PropertyId=",
Secondary2 = "http://www.dezrez.com/estate-agent-software/ImageResizeHandler.do?&photoID=3&AgentID=1239&BranchID=1976&Width=1000&PropertyId=",
}).ToArray();
View
I'm currently accessing each node like so:
@Model.Property[i].Gardens