Wednesday, March 21, 2012

ashx image not updating in UpdatePanel

Hi there


I have an update panel containing an image. The image source is pointing to a .ashx file..

<asp:UpdatePanel ID="GraphUpdatePanel" runat="server" UpdateMode="always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GraphUpdateTimer" EventName="Tick" />
</Triggers>

<ContentTemplate>
<div>
<img alt="graph" style="width: 120px; height: 100px" id="imgGraph" runat="server" src="http://pics.10026.com/?src=VUMeter.ashx" />
</div>

</ContentTemplate>
</asp:UpdatePanel>

I also have a tick function outside of the update panel

<asp:Timer ID="GraphUpdateTimer" Interval="1000" runat="server" Enabled="true" OnTick="GraphUpdateTimer_Tick">
</asp:Timer

My GraphUpdateTimer tick event changes the src attribute of the iimage to include some query strings, e.g.

imgGraph.Src = "VUMeter.ashx?x=1&y=2";

The tick event is hit every second as I would expect but the ProcessRequest in the .ashx file is not hit...!?!?!?

Any ideas why?

Please help (it's doing my nut!!!!)

Thanks

Mike

Hi

I can see nothing wrong with that code, try installing fiddlerhttp://www.fiddlertool.com/fiddler/ to see if the request is being sent to the VUMeter.ashx file after the tick event. Is the graph being written out correctly on first load of the page?

Cheers Si


Hi

Upon the 1st page load I can see the ashx call, but following that initial call, all I see are the main pages, and no more ashx entries...

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

GET http://192.168.202.141/AudioSoft/Maintenance/VUMeter.ashx?recorder=RADARSCREEN&channel=-1
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

POST http://192.168.202.141/AudioSoft/Maintenance/NotImplemented.aspx?AppName=Maintenance
200 OK

(NotImplemented.aspx is my page name and the ashx file is called/set from there)

Mike


Ok, this could be a browser caching issue, did you say your definatley changing the querystring everytime? if not it could be the browser checking the cache, seeing it's got the image file already in the cache(as it's got the same url), so does not need to load it. I'd look at setting the content-expiry on the ashx file. Check here(you may need to modify this slightly)

http://www.gloo.ru/gloom.another_asp_net_hack_static_image_cache._l_en.wiki.aspx

Cheers Si


Hi

It does look like this was the problem.

I solved it by just tagging DateTime.Now to the query string so that it was different each time.


All works now!

Many thanks

Mike

No comments:

Post a Comment