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

Forums / Developing with Sitefinity / using session vairable when missing page extension

using session vairable when missing page extension

4 posts, 1 answered
  1. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    17 Sep 2010
    Link to this post
    I have tried to resolve this to no end...  I hope you can help.

    Our marketing dept. wants to promote landing pages that are part of the website -  without the page extension (.aspx)
    www.mywebsite.com/landing_page
    The part that is causing an error is that I have the login view control on all pages.  I can get this to work if the user is not logged in, however, if they hit a page and it doesn't have it's extension, and they are logged in, it will error with either:
    "The name 'HTTPContext' doesn not exist in the current context"
    or
    Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.

    I have done everything i can think of.. added <pages enableSessionState="true">  to web.cong, tried using code at the bottom of this page, adding a defualt.aspx page with a redirect under the main page, etc...  It is just a problem of landing on the page without the extension... 

    Any ideas?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Sep 2010
    Link to this post
    Hello Laura,

    Try adding runAllManagedModulesForAllRequests="True" as an attribute to the system.webServer/modules element in web.config. This should set up the session state.

    Also make sure that you have SessionStateModule  registered as the error suggests.

    <add type="System.Web.SessionState.SessionStateModule" name="Session"/>

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    21 Sep 2010
    Link to this post
    Thank you, it seems to be working! :)

    Asking some advice --  If I want to put a login link in a template (inside some text on the page - in addition to the LoginVew link at the top of EVERY page on the site)  should I use a version of the LoginView control so that I can utilize the automatic appending of the ReturnUrl in the  URL? Otherwise if i just link to the login page I won't get the Return URL parameter to return back to the page (which will be different depending on the page it is sitting on)..  OR should I reate a separate control that looks for the page it is sitting on and gets the URL and create the URL dynamically pulling in the url for hte ReturnUrl... ? 

    For example - some text in a sidebar on a number of pages:
    If you are not a member, please join now.
    If you are a member, please *log in* now.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Sep 2010
    Link to this post
    Hello Laura,

    Routing with login controls like ASP.NET Login is performed internally by these controls depending on the LoginUrl property of FormsAuthentication class . You can force returning back to the destination page inside its LoggedIn event. or another event of the standard ASP.NET Controls. These controls look for an authentication cookie. If it fails to find the authentication cookie, the user is redirected to the configured logon page (Login.aspx), as specified by the LoginUrl attribute of the forms element. The user supplies and submits credentials through this form. Information about the originating page is placed in the query string using RETURNURL as the key.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 1 answered