WebMethod 缓存未进入处理程序的图像

发布于 2024-09-30 22:25:56 字数 727 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝海 2024-10-07 22:25:56

是的,这是缓存问题,浏览器缓存了处理程序的结果,当您再次调用处理程序时,浏览器返回缓存的结果。

为了防止缓存,您需要在将流写入 context.Response.OutputStream 之前在处理程序中设置它

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文