locked
Capture Session Value From Another ASP.net Application RRS feed

  • Question

  • User-1497865751 posted

    Hello ,

                 I have a web application and inside that I am using another web application in Iframe (as gadget). Is there any way I can share the session variable among the two sites? Please note that my two applications may be hosted in different servers.
                                      My requirement is when a user logged into the main site, they can work on this gadget and save information. So I need to get the user id of the main website to hold the information for that particular user in my database for gadget (which is working as another standalone application). Means I don’t need a separate login for the application inside Iframe. Please share your thoughts..

    Saturday, September 22, 2012 2:00 AM

Answers

All replies

  • User-1236380946 posted

    This could be Done with Shared Session Module.

    Following Link may Help you Out

    http://www.codeproject.com/Articles/27090/Sharing-Session-Across-Applications

    OR U can use SQL Server Session Mode but its going to be overhead of Serealization and De-Serialization

    Saturday, September 22, 2012 6:01 AM
  • User-1497865751 posted

    I tried a lot with the  codeproject.com article on 'Sharing Session Across Applications' but it didnt worked for me. Can anyone help me with some sample code so that things would be more Clear?

    Sunday, September 23, 2012 11:23 PM
  • User1849925139 posted

    Hi,

    You can share the session across the multiple application within the same server, only you need to implement the SQLServer session, StateServer, or Custom Session mode. Before explaining how to do I have some notes.

    Why we need to use these modes instead "InProc"?

    Answer is session in "InProc" creats in the IS meory, where as other web application have the restriction to eaccess the session.

    What exactly is the session?

    Session ID is the combination of ApplicationName + the randomly generated encryted value. So each application have the different name.

    For example WebApplication1 will have the application name as "WebApplication1" and webapplication2 will have the application name as "WebApplication2". So you need to have the same application name to be shared across the multiple web application to which you intended to share.

    How to do this?

    Use the SQLSession mode for the server and create the data base where you need to store the session(by default ASPState DB) using the command "aspnet_regsql -S <SQlServername> -ssadd -U <userID> -P<password>" in .net command prompt. If you using the windows authentication then us -E insted -U and -P.

    Now you modify the stroed proc found in the ASpState DB called as "TempGetAppID", by hardcoding the input param "@appName" value to any thing eg. "TEST". Now you must be able to share the session across the applications.

    Note: This is the hack.

    -----------------------------------------------

    Regards,

    Santosh Gada

    (If you find this soultion works, please mark as "Answered")

    Monday, October 1, 2012 3:24 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 4, 2012 1:19 AM