I have list of cities on my site, this list placed in Site.Master and look like:
<a id="<%= selectedCity.CityId %>"><%= selectedCity.Name %></a>
<ul>
...
<li id="<%= city.CityId %>" >
<%= Html.ActionLink(city.Name,"ChangeCity",new{ newCityId = city.CityId })%>
</li>
...
</ul>
Next, all my controller are based from BaseController, it contain next code:
public int CityId {get;set;}
protected override void OnActionExecuting(ActionExecutingContext filterContext){
if (filterContext.ActionDescriptor.ActionName.ToLower() != "changecity"){
this.CityId = Convert.ToInt32(Request.Cookies["SiteCityId"]);
var city = LoadCity(this.CityId);
var cities = LoadAllCities();
CitiesModel model = new CitiesModel() { selectedCity=city, allCities=cities};
ViewData["citiesModel"] = city;
}
else{
Response.Cookies["SiteCityId"]=filterContext.ActionParameters["newCityId"];
}
}
In all my controllers I was add next action:
[HttpGet]
public ActionResult ChangeCity(string newCityId)
{
return RedirectToAction(this.MyDefaultAction);
}
Main question: this schema not so good work. In IE8 sometimes I cant change current city use links like next:
http://www.mysite.com/home/changecity/?newCityId=3
And what you think about this schema at all? May be you use other methods for create functionality?