国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

消除圖片在ie中緩存而無法更新的問題

2024-07-21 02:23:24
字體:
供稿:網(wǎng)友
程序中圖片是動(dòng)態(tài)顯示的

原先把打算把圖片保存在服務(wù)器端然后顯示

可是由于ie的緩存問題導(dǎo)致圖片無法實(shí)時(shí)更新顯示

所以改為把圖片存在session中然后再顯示

需要保存的時(shí)候再保存到本地

//--------------chart.ashx.cs-------------------

using system;
using system.web.sessionstate;
using system.io;
using system.web;

namespace webapplication3
{
/// <summary>
/// chart 的摘要說明。
/// </summary>
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.writeto (ctx.response.outputstream);
memstream.close ();

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

}
}
}

//--------------chart.ashx 只需要如下一行---------------

<% @ webhandler language="c#" class="webapplication3.charthandler" codebehind="chart.ashx.cs" %>

//webapplication3為命名空間

//charthandler為chart.ashx.cs中類的名字



//--------------調(diào)用說明-----------------

//需要把圖片存到byte數(shù)組中 假設(shè)為bytearr 則

// ------------------------------------------------------------------------
//把圖片儲(chǔ)存在session里面
// ------------------------------------------------------------------------
httpcontext ctx = httpcontext.current;
string chartid = guid.newguid ().tostring ();

ctx.session [chartid] = bytearr;
image1.imageurl = string.concat ("chart.ashx?", chartid);



發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临桂县| 托克逊县| 高安市| 恭城| 乌兰察布市| 扎鲁特旗| 灌南县| 泰宁县| 科尔| 嘉荫县| 安宁市| 依安县| 凤山县| 谢通门县| 抚州市| 台南县| 日土县| 蓝田县| 慈利县| 侯马市| 宁河县| 镇雄县| 淮阳县| 西林县| 澎湖县| 兰坪| 江津市| 曲周县| 麻栗坡县| 康保县| 灵川县| 呼玛县| 石楼县| 年辖:市辖区| 鄯善县| 清远市| 色达县| 拜泉县| 成安县| 射洪县| 东城区|