Eliminate pictures Cacked in IE and cannot be updated

xiaoxiao2021-03-06  104

The picture in the program is dynamically displayed

I originally saved the picture in the server and then displayed.

However, because the cache problem of IE causing pictures to update the display in real time

So change to the existence of the picture and then display

Save it to the local time when you need to save

//-----------------------------------------

Using system; usingstate; using system.io; using system.Web;

Summary description of Namespace WebApplication3 {///

///. /// public class ChartHandler: IHttpHandler, IReadOnlySessionState {public bool IsReusable {get {return true;}} public void ProcessRequest (HttpContext ctx) {string chartID = ctx.Request.QueryString [0]; Array arr = ( Array) CTX.Session [chartid];

Ctx.clearerror (); ctx.response.expires = 0; CTX.Response.buffer = true; ctx.response.clear ();

MemoryStream Memstream = New MemoryStream ((Byte []) Arr); Memstream.Writtream; Memstream.close ();

Ctx.response.contentType = "image / gif"; ctx.response.statuscode = 400; ctx.response.end ();

}}}

//--------------Chart.ashx only needs the following line ---------------

<% @ Webhandler Language = "C #" class = "WebApplication3.ChartHandler" CodeBeHind = "Chart.ashx.cs"%>

// WebApplication3 is named space

// charthandler is the name of CHART.ASHX.CS

// -------------- Call Description ----------------- // Need to save the picture to the Byte array assumption to bytearr

/ / -------------------------------------------------------------------------------------------- ------------------------ // Store the picture in Session // ---------------- -------------------------------------------------- ------ httpContext CTX = httpContext.current; string chartid = guid.newguid () .tostring (); ctx.session [chartid] = Bytearr; Image1.imageURL = String.concat ("Chart.ashx?", ChartID); Supplementary Description: The file with ASHX is HTTP Handlers, SimpleHandlerFactory event factory knows how to compile this file and instantiate the IHTTPHANDLER interface, no need to configure web.config does not need to update IIS extension mappings

转载请注明原文地址:https://www.9cbs.com/read-100706.html

New Post(0)