Sanjay Surendra
Sanjay Surendra

Reputation: 47

ashx handler called only once from ascx page

In .ascx page i have image button as follows:

"<asp:Image ID="imgPhotos" runat="server" Width="102" Height="82"/>"

In its code behind, I have:

this.imgPhotos.ImageUrl = "~/lib/services/GetSpaceImage.ashx";

In GetSpaceImage.ashx, i am dynamically generating images. But the problem is, for the first time it works good. But, second time and so on it never generate the new images. Debugger hits hanlder only for the first time(when the application loads). I have tried using: "context.Response.Cache.SetCacheability(HttpCacheability.NoCache);"

at the beginning of the ProcessRequest. But this also did not help. Am i missing anything? Please advice

Upvotes: 1

Views: 1074

Answers (1)

Antonio Bakula
Antonio Bakula

Reputation: 20693

Browser cached this request, add unique param to every ashx url, something like this :

this.imgPhotos.ImageUrl = "~/lib/services/GetSpaceImage.ashx?param=" + DateTime.Now.Ticks.ToString();

Upvotes: 1

Related Questions