Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • aghy 129 posts 308 karma points
    May 29, 2010 @ 23:35
    aghy
    0

    SessionID within base

    Hi All,

    All I want to do is be able to keep a users session while they are on my site. 

    At the moment I am trying to retreive the SessionID from within a base method by using jQuery.post() to call the base url:

    public class HelloWorldTest : IRequiresSessionState
    {
    public static string Hello()
    {
    HttpContext hc = HttpContext.Current;
    if (hc.Session == null)
    {
    return "oops";
    }
    return "Hello" + hc.Session.SessionID;
    }
    }

    But the HttpContext.Current.Session is always null. 

    I can get the SessionID within XSLT but I need to be able to set a session variable after the page has loaded.

    Imagin a user fills in a textbox on page one, and presses submit.  I want to be able to save that input and display it to them on every page they navigate to within my site.

    I would prefer not to have to use a usercontrol as in the future I will need to make this only be shown on certain pages and I know usercontrols cannot be called from XSLT.

    I am working locally using UltiDev Cassini Web Server for ASP.NET 2.0 with umbraco 4.0.3

    Any help at all would be fantastic I've been stuck on this for over a week now!

    Thanks

    aghy

  • aghy 129 posts 308 karma points
    May 30, 2010 @ 04:42
    aghy
    0

    Actually using this forum helped me figure this one out. Actually it was this

    httpcontextuser is null in base httpmodule

    that helped the most.

    Then all you have to do is got to the link mentioned by Morten Bock which is umbraco.codeplex

     

  • aghy 129 posts 308 karma points
    May 30, 2010 @ 04:47
    aghy
    0

    and copy the code you see there into a .cs file.  Give it a different class name so instead of

    public class requestModule : IHttpModule, IRequiresSessionState

    call it

    public class newRequestModule : IHttpModule, IRequiresSessionState

    then compile it and put the .dll into your bin directory.

    Then go to your web.config and change

    <add name="umbracoBaseRequestModule" type="umbraco.presentation.umbracobase.newRequestModule" /> 

    to

    <add name="umbracoBaseRequestModule" type="umbraco.presentation.umbracobase.newRequestModule" /> 

     

    I dont know if this is the correct way of doing things but this has definatly helped me and I'm just trying to make it clearer for those that have a similar problem.

    aghy

Please Sign in or register to post replies

Write your reply to:

Draft