More in this section

Forums / Developing with Sitefinity / Capturing Session Start QueryString

Capturing Session Start QueryString

4 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    04 Mar 2009
    Link to this post
    Morning everyone,

    The site i am building allows for our different wholesalers to enter the website with a querystring that is captured on Session_Start and held. This value then determines what pricing to run the website under...

    Now with the CMS this seems to work a little different. I tried doing the following which is what we do on our current website in the global.asax:

    void Session_Start(object sender, EventArgs e)  
        if (Request.QueryString["actas"] != null
        { 
            Engine.EngineSessionData engineConfig = new Engine.EngineSessionData(); 
            engineConfig.SessionWholesaler = Request.QueryString["actas"].ToString(); 
        } 

    But when i navigate to http://localhost/MySite/default.aspx?actas=wholesalername it does not capture the QueryString cause it seems as though the CMS request is for sitefinity/cmsentrypoint.aspx.

    Could someone please share with me the proper way of doing something like i explained above, maybe the CMS has something built in to accommodate such functionality?

    Thanks,

    Duncan
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    09 Mar 2009
    Link to this post
    Hi Duncan,

    The problem is that if you request http://localhost/MySite/default.aspx?actas=wholesalername, Sitefinity is doing redirect to the page. There are two possible things you could do:
    • If you request a page that exists, and it is InternalPage (a page created in Sitefinity), the query string should be carried to the requested page and your code would work
    • If you set:
      <cms defaultProvider="Sitefinity"  
       pageExtension=".aspx"  
       projectName="3six" 
       disabled="false"  
       pageEditorUIMode="Overlay"  
       redirectToHomePage="false"
      in the web.config file, then Sitefinity will not a permanent redirect to your page (and lose the query string) but will rather rewrite the path and taking into account the query string.
    I personally prefer the second option, because using the first one, you should always ensure that you have the requested page, and it is a CMS page.
    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    10 Mar 2009
    Link to this post
    Hi Georgi,

    I want the site top redirect to the home pages, so i would not want to set this to false... i do agree with you that creating a sort of "landing page" specifically for this purpose would also not be an option.

    Is there perhaps some override i can perform BEFORE the redirect happens where i can capture the querystring? Or maybe i can take advantage of urlrewriting in some manner... Something like http://localhost/MySite/wholesalername/ but send this to the home page with a query string?

    And where would be the optimal place to capture such a query... Session_Start might not be?

    Any other thoughts on this?

    Duncan
  4. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    16 Mar 2009
    Link to this post
    Hi Duncan,

    The problem is not related to the place, the QueryString is captured (Session_Start).
    For example, lets say that you have the default cms configuration settings:
    <cms defaultProvider="Sitefinity"  
         pageExtension=".aspx"  
         defaultDocument="default.aspx" 
         redirectToHomePage="true" 
     

    and your cms homepage is:  ~/home.aspx.

    So, if request the site with:

    http://localhost/MySite/default.aspx?actas=wholesalernam

    Because of defaultDocument attribute is set to default.aspx, Sitefinity decides, that this is a request to the home page, and because of redirectToHomePage is set to true, Sitefinity redirects it
    ~/home.aspx, but without the query string.
    Seems we haven't considered such scenario and therefore our CMS does permanent redirect without the QueryString. We will fix this
    omission for the upcoming release.

    However, we suggest you to use the real home page URL (if possible), i.e.:

    http://localhost/MySite/home.aspx?actas=wholesalernam
    .

    Alternatively, you can use the advanced URL rewriting (see the URL Rewriting topic in the User Manual or http://www.sitefinitywatch.com/blog/08-12-23/URL_Rewriting_with_Sitefinity_Webinar.aspx) with a rule like this:
    <rule> 
        <url>/default.aspx?(.*)</url> 
        <rewrite>/home.aspx?$1</rewrite> 
    </rule> 
    However, this solution has the same effect like those in our previous reply.

    Sorry for the inconvenience. Your telerik points were updated for reporting this issue.

    Regards,
    Vlad
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered