Asp.net System.Web.HttpContext.Current.Session null in global.asax

45

Solution 1

John,

I'm assuming you're using an ashx handler for the handler. If so, be sure to derive from IRequiresSessionState for example:

public class Images : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{ }

If you're not using an ashx can you describe what you mean by dynamic image page?

Josh

Solution 2

Session has nothing to do with being logged in or not.

What event are you overriding when you want access to the session? Session isn't available until AcquireRequestState has been fired.

For more information, see: http://msdn.microsoft.com/en-us/library/9ysfzy8h.aspx

Share:
45
tanu
Author by

tanu

Updated on March 29, 2020

Comments

  • tanu
    tanu over 4 years

    I have the following datagrid:

    <controls:MDataGrid id="holdrules_datagrid" width="100%" height="100%"
                                          allowMultipleSelection="true" dataProvider="{holdRuleDataList.holdRuleDataList}" >
    

    I am trying to get all the selected rows from this, but the value is not getting stored, and is giving me null in the Java layer

    var arr:ArrayCollection = new ArrayCollection;
    arr = holdrules_datagrid.selectedItems as ArrayCollection
    

    Can anyone please help me with what is wrong here?

    • tanu
      tanu over 9 years
      <controls:MDataGrid id="holdrules_datagrid" width="100%" height="100%" allowMultipleSelection="true" dataProvider="{holdRuleDataList.holdRuleDataList}" >
  • JohnC
    JohnC over 15 years
    Session has everything to do with my custom business principle. The problem lies in that session is null only for this one page, the 50 or so others in this large application do not exhibit this issue. I access Session from Application_PostAuthenticateRequest where it's normally not an issue.
  • JohnC
    JohnC over 15 years
    For the sake of this issue, just ignore the whole business principal part, the fundamental problem is that Session is null only for this one type of page.
  • JoshBerke
    JoshBerke over 15 years
    Jon what type of page is it? Is this an aspx? or ashx?
  • JohnC
    JohnC over 15 years
    Hi Josh, You're my favorite person right now! :) No I was using a standard aspx page because all the examples about handlers mentioned using a file extension and config changes, didn't know about ashx at all, tried it, and it did require the derivation you mentioned. Works perfectly. Cheers!
  • JoshBerke
    JoshBerke over 15 years
    Heh awsome! I love ashx handlers. I've used one to pull images from a database which works really well. I've also found that if your doing a POX Service that the ashx works out very well.