WebMethod 缓存未进入处理程序的图像
我有一个 WebMethod 接收 HTML 作为参数,如下所示:
Public Function ConvertHtmlToPdfListAnswer(ByVal dokument As Dokument) As Byte()
在这个 HTML 中,我的用户签名路径如下所示:
Handlers/SzablonyListImgHandler.ashx?usid=2006
我的处理程序如下所示:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
它从上下文中获取参数,创建数据库查询并返回流输出,如下所示:
If Not String.IsNullOrEmpty(context.Request.QueryString("usid")) Then
...
...
streamOut.WriteTo(context.Response.OutputStream)
我的问题是它只触发一次...我的意思是,当我再次调用该服务时,它不会进入处理程序,但当我在调试器视图中检查 HTML 时,它已经向我显示了图像。因此,当用户更改数据库中的签名时,服务方法仍然返回前一个...我认为这可能是某种 chache 问题...有什么想法吗?
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是缓存问题,浏览器缓存了处理程序的结果,当您再次调用处理程序时,浏览器返回缓存的结果。
为了防止缓存,您需要在将流写入 context.Response.OutputStream 之前在处理程序中设置它
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