开发者

WebMethod Caches images not entering handler

开发者 https://www.devze.com 2023-01-23 09:35 出处:网络
I have a WebMethod that recives HTML as parameter somthing like this: Public Function ConvertHtmlToPdfListAnswer(ByVal dokument As Dokument) As Byte()

I have a WebMethod that recives HTML as parameter somthing like this:

Public Function ConvertHtmlToPdfListAnswer(ByVal dokument As Dokument) As Byte()

In this HTML my path to for example user signature looks like this:

Handlers开发者_运维问答/SzablonyListImgHandler.ashx?usid=2006

My handler starts like this:

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

and it takes parameter from context, creates query for databese and returns stream output like this:

If Not String.IsNullOrEmpty(context.Request.QueryString("usid")) Then
...
...
streamOut.WriteTo(context.Response.OutputStream)

My problem is that it fires onle once...what I mean is that when I call the service again it doesn't enter the handler but it already shows me the image when i check the HTML in debugger view. So when The user changes his signature in database the service method still returns the previous one...I think it could be some kind of chache problem...Any ideas??


yes this is the cache problem, browser caches the result of handler, and when you call the handler again, browser returns the cached result.

to prevent caching you need to set this in the handler before you write stream to context.Response.OutputStream

context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号