Briefly: Session State in Generic Handler doesn't work in FireFox
Detailed: I use jquery uploadify to upload an image to the webserver. In a generic handler that implements IRequiresSessionState I store the image as a byte in an object. That object is than placed inside a Session variable that I later will pick
up to store the image into the database.
Everything goes well in Internet Explorer 8 but it fails in FireFox. The Session variable created in the generic handler is Nothing.
Generic handler:
<%@ WebHandler Language="VB" Class="SetFotoDemandante" %>
Option Strict On
Imports System.Web
Imports CsiCom.CapaNegocio
Imports System.IO
''' <summary>
'''
''' </summary>
Public Class SetFotoDemandante : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState
''' <summary>
'''
''' </summary>
''' <param name="context"></param>
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim httpFile As HttpPostedFile
If (Not context.Request.Files("Filedata") Is Nothing) Then
httpFile = context.Request.Files("Filedata")
Dim iFileLength As Integer = httpFile.ContentLength
If (iFileLength <> 0) Then
' Save in to a foto object.
Dim baInput(iFileLength) As Byte
httpFile.InputStream.Read(baInput, 0, iFileLength)
Dim negObjFotoDemandante As New Neg_ObjFotoDemandante()
negObjFotoDemandante.Foto = baInput
negObjFotoDemandante.FileName = httpFile.FileName
negObjFotoDemandante.FileExtension = New FileInfo(httpFile.FileName).Extension
negObjFotoDemandante.ContentType = httpFile.ContentType
' Save in Session, this session will be picked up later.
context.Session.Item("negObjFotoDemandante") = negObjFotoDemandante
context.Response.Write("1")
End If
End If
End Sub
''' <summary>
'''
''' </summary>
''' <value></value>
''' <returns></returns>
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
The code behind that fails in Firefox:
Protected Sub imgbtnHbtnCompleteFotoUpload_Click(ByVal sender As Object, ByVal e As EventArgs)
' Load session
If (Session.Item("negObjFotoDemandante") Is Nothing) Then
ShowPrompt("Failed to insert the photo.<br/><br/>Error message: A session problem occured.")
Exit Sub
End If ...
ESTAN
Member
2 Points
12 Posts
Session State in Generic Handler doesn't work in FireFox
Aug 25, 2009 12:40 PM|LINK
Hi,
Briefly: Session State in Generic Handler doesn't work in FireFox
Detailed: I use jquery uploadify to upload an image to the webserver. In a generic handler that implements IRequiresSessionState I store the image as a byte in an object. That object is than placed inside a Session variable that I later will pick up to store the image into the database.
Everything goes well in Internet Explorer 8 but it fails in FireFox. The Session variable created in the generic handler is Nothing.
Generic handler:
<%@ WebHandler Language="VB" Class="SetFotoDemandante" %> Option Strict On Imports System.Web Imports CsiCom.CapaNegocio Imports System.IO ''' <summary> ''' ''' </summary> Public Class SetFotoDemandante : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState ''' <summary> ''' ''' </summary> ''' <param name="context"></param> Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim httpFile As HttpPostedFile If (Not context.Request.Files("Filedata") Is Nothing) Then httpFile = context.Request.Files("Filedata") Dim iFileLength As Integer = httpFile.ContentLength If (iFileLength <> 0) Then ' Save in to a foto object. Dim baInput(iFileLength) As Byte httpFile.InputStream.Read(baInput, 0, iFileLength) Dim negObjFotoDemandante As New Neg_ObjFotoDemandante() negObjFotoDemandante.Foto = baInput negObjFotoDemandante.FileName = httpFile.FileName negObjFotoDemandante.FileExtension = New FileInfo(httpFile.FileName).Extension negObjFotoDemandante.ContentType = httpFile.ContentType ' Save in Session, this session will be picked up later. context.Session.Item("negObjFotoDemandante") = negObjFotoDemandante context.Response.Write("1") End If End If End Sub ''' <summary> ''' ''' </summary> ''' <value></value> ''' <returns></returns> Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End ClassThe code behind that fails in Firefox:
Protected Sub imgbtnHbtnCompleteFotoUpload_Click(ByVal sender As Object, ByVal e As EventArgs) ' Load session If (Session.Item("negObjFotoDemandante") Is Nothing) Then ShowPrompt("Failed to insert the photo.<br/><br/>Error message: A session problem occured.") Exit Sub End If
...
Can anyone help me out finding this odd problem?