SilverlightのWebClientがたまにリクエストを飛ばしてくれない
Silverlight+T2でちょいちょいサンプル作っているのですが、汁バラのWebClientがたまにリクエストを飛ばしてくれない。
なんだか勝手に自分が抱えてるキャッシュを返してくるコマッタちゃんです。
んー、どうすればいいんかなあ。
(追記)
あー、WebClientはcacheしてしまうそうです。しかもCachePolicyは汁バラの抱えてるdllでは
入ってないことを確認orz
なんかもうめんどいので伝統的な方法(適当なクエリストリングでキャッシュさせない)でいくことにw
string url = Const.URL_BASE + "list?hogehogefoo=" + DateTime.Now.ToString(); WebClient client = new WebClient(); client.DownloadStringCompleted += (_s, _e) => { if (_e.Result != null && !_e.Result.Equals("")) { string xml = _e.Result; XDocument xdoc = XDocument.Parse(xml); XElement list = xdoc.Element("List"); IEnumerable<XElement> employees = list.Elements("Employee"); List<EmployeeDto> emps = new List<EmployeeDto>(); foreach (XElement emp in employees) { EmployeeDto employee = new EmployeeDto(); employee.empId = (int)emp.Element("empId"); employee.empName = (string)emp.Element("empName"); employee.sal = (decimal)emp.Element("sal"); employee.job = (string)emp.Element("job"); employee.hiredate = (DateTime)emp.Element("hiredate"); emps.Add(employee); } EmpList.ItemsSource = emps; if (callback != null) { DispatcherUtil.applyCallback(this.Dispatcher, callback); } } else if (_e.Error != null) { Console.WriteLine(_e.Error.Message); } detail.callback = null; }; client.DownloadStringAsync(new Uri(url));
kimoy.