XAP cached and no way clearing the cache!
hello! built small silverlight app , published on hosting. works fine. later made changes app (added new controls, changed text, etc) , published again. when i'm in office still see old version. tried cleaning browser's cache - didn't help. when open app home - ok, see new version. difference company uses isa server , guess cached xap file, user have no way cleaning cache. tried use outputcache directive on webform hosts silverlight control had no effect... can here? thanks, alex
you use ihttphandler instead of direct link .xap file. means the url .xap file should be changed from "webapp/slapp.xap" "webapp/handler.axd?source=slapp.xap". you will able to add parameter last url, example build number: "webapp/handler.axd?source=slapp.xap&buildno=1234". after upgrading silverlight application have change url parameter "buildno".
1 public class xaphandler : ihttphandler 2 { 3 #region ihttphandler members 4 public bool isreusable 5 { 6 get { return true; } 7 } 8 9 public void processrequest(httpcontext context) 10 { 11 string urlpath = context.request.params["source"]; 12 if (string.isnullorempty(urlpath)) 13 { 14 context.response.statuscode = 404; 15 return; 16 } 17 string physicalfilename = context.request.mappath(urlpath); 18 if (!system.io.file.exists(physicalfilename)) 19 { 20 context.response.statuscode = 404; 21 return; 22 } 23 context.response.statuscode = 200; 24 context.response.contenttype = "application/x-silverlight-2"; 25 try 26 { 27 system.io.filestream stream = new system.io.filestream(physicalfilename, system.io.filemode.open, system.io.fileaccess.read, system.io.fileshare.none); 28 try 29 { 30 byte[] buffer = new byte[4096]; 31 int bytesread = 0; 32 do 33 { 34 bytesread = stream.read(buffer, 0, buffer.length); 35 context.response.outputstream.write(buffer, 0, bytesread); 36 } while (bytesread == buffer.length); 37 } 38 finally 39 { 40 stream.close(); 41 } 42 } 43 catch 44 { 45 context.response.statuscode = 500; 46 return; 47 } 48 context.response.outputstream.flush(); 49 } 50 51 #endregion 52 } 53
don't forget register http handler in web.config file.
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment