I have an Handler.ashx file and on .aspx page load it calles the .ashx file for image reading. I am attempting to pass a session from the .aspx file to the .ashx file in order to make my query of grabing the image secure. The problem is that everytime
I call a session: HttpContext.Current.Session["ID"], the value is returning null or errors saying the o so commong "Object reference not set to an instance of the object". I have tried a couple ways of grabing the session:
1.) context.Session["ID"]
2.) HttpContext.Session["ID"]
3.) HttpContext.Current.Cache["ID"]
none of them are giving me the ID session set in the .aspx page. should i be using Server.Transfer instead? is there a way to grab a session variable set in a .aspx page and called in a .ashx page?
this doesnt work for me! anyone else have any suggestions???
i have this implemented 100% per hs instructions -- and still get nullreferenceexceptions
using System;
using System.Web;
using System.Web.SessionState;
using System.Text;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
public class EmailSignup : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest (HttpContext context) {
NUStudent
Member
43 Points
112 Posts
.aspx sessions being called in .ashx handler
Jul 02, 2010 02:51 PM|LINK
I have an Handler.ashx file and on .aspx page load it calles the .ashx file for image reading. I am attempting to pass a session from the .aspx file to the .ashx file in order to make my query of grabing the image secure. The problem is that everytime I call a session: HttpContext.Current.Session["ID"], the value is returning null or errors saying the o so commong "Object reference not set to an instance of the object". I have tried a couple ways of grabing the session:
1.) context.Session["ID"]
2.) HttpContext.Session["ID"]
3.) HttpContext.Current.Cache["ID"]
none of them are giving me the ID session set in the .aspx page. should i be using Server.Transfer instead? is there a way to grab a session variable set in a .aspx page and called in a .ashx page?
Any suggestions would be appreciated,
- NUStudent
MetalAsp.Net
All-Star
112095 Points
18242 Posts
Moderator
Re: .aspx sessions being called in .ashx handler
Jul 02, 2010 04:42 PM|LINK
Does your ashx imlpement the IReadOnlySessionState interface?
Refer: http://www.hanselman.com/blog/GettingSessionStateInHttpHandlersASHXFiles.aspx
wints9er
Member
2 Points
3 Posts
Re: .aspx sessions being called in .ashx handler
Jul 22, 2010 10:21 PM|LINK
this doesnt work for me! anyone else have any suggestions???
i have this implemented 100% per hs instructions -- and still get nullreferenceexceptions
using System;
using System.Web;
using System.Web.SessionState;
using System.Text;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
public class EmailSignup : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest (HttpContext context) {
context.Response.Write(context.Session["id"].toString());
}
}
<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">
<div id="refHTML"></div><input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">
<div id="refHTML"></div>hans_v
All-Star
35986 Points
6550 Posts
Re: .aspx sessions being called in .ashx handler
Jul 22, 2010 10:29 PM|LINK
If you've a question, start your own thread?
http://www.mikesdotnetting.com/Article/69/How-to-get-your-forum-question-answered-avoid-thread-jacking