+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Session Issue

Session Issue

5 posts, 1 answered
  1. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    03 Dec 2009
    Link to this post
    I created a user control, which checks user session. I put it on the homepage, default.aspx.
    When I browse the homepage http://www.mysite.com/, it generates the following error; however, if I browse the page http://www.mysite.com/default.aspx, it shows fine. Can you help me out? Thanks.


    Server Error in '/' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 78:             get {
    Line 79: 
    Line 80:                 Session s = (Session) HttpContext.Current.Session[SessionKey];
    Line 81:                 if (s == null)
    Line 82:                 {

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Dec 2009
    Link to this post
    Hi Stephen,

    Thank you for using our services.

    Are you trying to get the session variable by the key index number or by the the key name? I can not tell by stack trace that you have posted. I have tested this on my local environment. First I have added default.aspx as a default document to my site in IIS. Then I have set up the default.aspx page in Sitefinity as my home page in the CMS. I have added the bellow in the page load event of my master page. It shows the same number of keys no matter if I access www.mysite.com or www.mysite.com/default.aspx:
    var currentContext = HttpContext.Current;
    Response.Write(currentContext.Session.Keys.Count.ToString());


    All the best,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    03 Dec 2009
    Link to this post
    Hi There,

    I'd like to point out that this is the exact problem I'm having which I posted here http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/combobox-not-working-when-aspx-page-not-in-url.aspx  and I've also submitted a ticket with sample that breaks. (easy to do, go to www.site.com/ and try to access anything in the HttpContext.Current, it will always be null). I'm still waiting for a response on the ticket (hint hint). Definitely an issue here as the exact same code will work if you have www.site.com/page.aspx 

    Just wanted to add this so that maybe more resources can be put to same problem.

    Cheers,
    Phill
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Dec 2009
    Link to this post
    Hello Phill Hodgkinson,

    Thank you for getting back to us.

    We are aware of this forum thread, and have tried to reproduce the issue however to no avail. We have started working on your support ticket also. I have tried the code that you have sent and it does not break on my side, so we need a little bit more time to investigate the issue. I have attached a screen cast that shows how the control you have sent behaves on my side (I am using the configuration for my site as from my previous posts). If the video wont play in media player try viewing it in a browser.

    As I mentioned above we are currently investigating your issue. Once we are done trouble shooting and have some answers and suggestions we will get back to you. I think that we will be able to respond to you by the end of the day.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    04 Dec 2009
    Link to this post
    For Stephen or anyone else who may be having this issue. I got a fix, and easy one, from Telerik in a support ticket. I thought I'd share here so everyone can benefit. The issue happens when you don't have a page in the url (i.e. you set redirectToHomePage="false") and somewhere you try to access the current session data (i.e. a session variable, the current user session, etc).

    The following are 3 options to fix the problem from Ivan at Telerik. He recommends the 1st option. 

    To fix the issue try one of the follwoing methods

    Option 1: Add the following attrribute to your web.confog file

    <system.webServer>
            <validation validateIntegratedModeConfiguration="false"/>
            <modules runAllManagedModulesForAllRequests="True">

    Option 2:

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="false">
            <remove name="ScriptModule"/>
            <remove name="Cms"/>
            <!--<remove name="LibraryModule"/>-->
            <remove name="RadUploadModule"/>
      <remove name="Session" />
      <add name="Session" type="System.Web.SessionState.SessionStateModule"/>

    Option 3. Run the website in Classic Application Mode.

    Kind regards,
    Ivan Dimitrov 
    the Telerik team

    Answered
Register for webinar
5 posts, 1 answered