Last post Sep 17, 2008 08:37 AM by jstranger
Sep 16, 2008 08:42 AM|jstranger|LINK
I am currently playing with the new GeneratedImage control, ImageHandler and ImageTransform classes available on Codeplex. I can display images and do basic transforms but have run into a problem when it comes to storing and accessing an image in a session
variable (which may not be elegant but has previously worked in other code). I have added Implements IReadOnlySessionState in my HTTP handler (which inherits Microsoft.Web.ImageHandler) and in my override of the GenerateImage method I can retrieve a simple
session string variable as follows:
Dim t As String = HttpContext.Current.Session("pic")
But if the variable is an Image or Bitmap then the assignment works but all of the properties are reported as 'Parameter is not valid'.
Presumably a simple error but I cannot figure it out. Any ideas?
Sep 17, 2008 08:37 AM|jstranger|LINK
Well I have resolved the problem but frankly do not understand it.
In my code behind I had something like:
Dim uploadpic As System.Drawing.Image = Image.FromStream(PicUpload.FileContent)
Session("pic") = uploadpic
Preview.Visible = True
and in the GenerateImage method of my HTTP handler I had:
Dim img As Image = HttpContext.Current.Session("pic")
Return New ImageInfo(img)
If I delete the Dispose statement all is well! Figure that.