You have multiple options to deal with this. Some of them are:
1. "\" is not a url friendly character. So you will have to
UrlEncode
your string when using it in html (for example in the "target" property). So changing the following
@Html.ActionLink("change", "changeCity", new { id = item.myCountyCity })
to
@Html.ActionLink("change", "changeCity", new { id = Server.UrlEncode(item.myCountyCity) })
On the controller, in your action method, you will have to "UrlDecode", like. Server.UrlDecode(id).
2. You can split your input by "\" and supply the action method with 2 parameters - country and city. So you action method would look like
public ActionResult Index(string country, string city)
{
return View();
}
And then your route will be
routes.MapRoute(
"CityCountyRoute",
"{controller}/{action}/{country}/{city}",
new { controller = "Home", action = "Index", county = @"\s+", city = @"\s+" });
where country and city are non-empty strings. Now you could have your Html.ActionLink call as
@Html.ActionLink("change", "changeCity", new { country = item.myCountyCity.Split('\\').First(), city = item.myCountyCity.Split('\\').Last() })
Even better way would be do this would be to do this in the controller and have these values in a model which is passed to the view. Because the lesser the amount of code in your views, better it is!
Hope this helps!