HttpHandlers and Session access

  • Thread starter damianarielfernandez
  • Start date
D

damianarielfernandez

Hi group, I read a lot about this problem and all the same answers
appears...Implement the IRequireSessionState or IReadOnlySessionState
interface...but the same problem arrays'...null session.

Anyone have a solution for this problem?. I'm on the GetHandler methods
inside my custom Hander!. Please group, people...and Good I' Ned your
help :p

Regards and Thanks!
 
M

MSDN

I use System.Web.SessionState.IRequiresSessionState and it works, no
implementation necessary.

SA
 
D

damianarielfernandez

Tanks for your reply, can you send me an example code?. Maybe I'm doing
something wrong.

This is my actual no working code :(

internal class CustomHandler: IHttpHandlerFactory,
IRequiresSessionState
{
public CustomHandler()
{

}

#region IHttpHandlerFactory Members

public void ReleaseHandler(IHttpHandler handler)
{

}

public IHttpHandler GetHandler(HttpContext context, string requestType,
string url, string pathTranslated)
{
Page compiledPage;

compiledPage =
PageParser.GetCompiledPageInstance(url,pathTranslated, context) as
Page;

HttpContext.Current.Session["myId"] --> null. The entired
Session object is null
 
M

MSDN

I only implement IHttpHandler and not IHttpHandlerFactory

then I use

HttpContext.Current.Session.Add("imgVal", imgVal)

This is in VB...

Public Class imageservice
Implements IHttpHandler
Implements System.Web.SessionState.IRequiresSessionState

Public Overridable ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return True
End Get
End Property


Public Overridable Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim oPic As Byte()
Dim imgVal As String
Try
.....
HttpContext.Current.Session.Add("imgVal", imgVal)
HttpContext.Current.Response.ContentType = "image/jpeg"
HttpContext.Current.Response.OutputStream.Write(...., 0, oPic.Length)
Catch ex As Exception
ExceptionManager.Publish(ex)
Throw ex
End Try


End Sub
..... any other private Subs here



Hope that helps

SA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top