Allow only Logged in user to download images
<p>I am working on an Application based on Monorails which generates images / charts at runtime. The code writes the images to OutputStreams and not to the Appserver hard drive. It allows the user to download the image. I want to make sure that only the logged in user is able to download the image and no one else. </p>

<p>For e.g if any user A tries to download image generated for user B user A should not be able to do that no matter what. </p>

<p>Note: I am not storing the file to the hard disk.</p>

<p>How can I implement this???</p>

<p>Below is the sample code I have written for the image download.</p>

<pre><code>var stream = new MemoryStream();
Response.Clear();
Response.ContentType = "application/image";
Response.AddHeader("Content-Disposition","attachment; filename=" + imagefilename);
var array = stream.To Array();
Response. OutputStream.Write(array,0,array.length);
Response.End();
</code></pre>

<p>Please help me fix this issue.</p>

<p>Thanks,
Rahul</p>
