Image handlers in ASP .NET
-
Hi I have an asp .net application that uses image handlers to generate and send images to users, the image handler has the property IsReusable = true which means it is reusable for multiple requests. I have two questions: 1. When serving multiple users simultanously, are users served on strict queue basis, which means that the image handler will not be serving "multiple requests" at the same time. To clarify: what I am worried about is something like the following scenario: I have two users A and B accessing the application simultanously, I have a static varible v (in the image handler) having its value changing depending on some criteria. Now is the following scenario possible: 1. User A requests an image 2. Depending on some user criteria I set v = 1 3. User B requests another image. 4. Before finishing user A's request, ImageHandler attemps to serve user B 5. Depending on some user criteria I set v = 2 6. Imagehandler finishes serving user B. 7. Image handlers switches continue serving User A, but v = 2 (depending on user B criteria) but it should be 1. Is the above scenario possible? My second question: My Image handler reads data from a database for every image in a simple manner: 1. open connection. 2. read data. 3. close connection. But because I know that only one copy of my image handler will be running so why not just open a connection in a static constructor and leave it open instead of opening/closing connections for every request? I think it will improve performance, but I am afraid that it is not a good practice. Thanks for everybody
And ever has it been that love knows not its own depth until the hour of separation Mohammad Gdeisat