locked
Pass session value from one project to another in same solution. RRS feed

  • Question

  • User-977583538 posted

    I have two project in single solution named as Main_Project and Sub_Project.

    In Main_Project I have Login.aspx page where I am writing value in Session after that I am redirecting to page which is in Sub_Project and in page load I want to read the session value which I have stored in Login page of project first.

    For this purpose I have used SQLServer session mode(http://www.beansoftware.com/ASP.NET-Tutorials/Store-Session-SQL-Server.aspx) where the session value has been saved in database but I am not able to read the session value in next page.

    I want to use server side and secure way to transfer session.

    So please reply with solution.

    Friday, March 20, 2015 8:29 AM

Answers

All replies

  • User724169276 posted

    AFAIK , you cannot use session to transfer values from one project to other , either use cookies , query strings or application variable , before you use application variables make sure both the projects share same application pool.

    Friday, March 20, 2015 8:34 AM
  • User-977583538 posted

    Thanks for reply.

    I want to use server side and secure way to transfer session.

    Saturday, March 21, 2015 1:00 AM
  • User-271186128 posted

    Hi Anuj Kathuria,

    From my point of view, even though your projects are in the same solution, they are still 2 different applications. So, I don't think we can use ASP.Net Session state for this purpose.

    As you said in your first post, we have to save those data somewhere like database or in a text file and access it from other project.


    where the session value has been saved in database but I am not able to read the session value in next page.

    Will you please explain more details about this issue? We need to use the same database in Main_Project and Sub_Project. Please check the connect string.

    Best Regards,
    Dillion

    Monday, March 23, 2015 3:26 AM
  • User724169276 posted

    Anuj_SwDeveloper

    I want to use server side and secure way to transfer session.

    If you want to have a secure way to transfer sensitive information then use cryptography in your query string and transfer the values , however you can use database also as a support but then it will be a round trip to send the information to database and retrieve it back , which i think is not a recommended way to approach.You can find tons of good articles on how to encript and decript the query string paramters , few of them is are jotted down :

    http://www.codeproject.com/Tips/583097/Global-Query-String-Encryption

    http://www.aspsnippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 23, 2015 3:40 AM
  • User-977583538 posted

    Dear Dillion,

    I have checked the connection string and its fine.

    I want to retrieve the session value stored in database in page exist in second project.

    SessionId Created Expires LockDate LockDateLocal LockCookie Timeout Locked SessionItemShort SessionItemLong Flags
    0baua14ud3oy52vkqkdq1zqea5e5228b 23:13.3 43:13.3 23:13.3 53:13.3 1 20 0 0x140000000000FF NULL 0
    0bmka4kuydyzyjnaonoljrdja5e5228b 54:40.0 14:40.0 54:40.0 24:40.0 1 20 0 0x140000000000FF NULL 0
    0mut0xd3opr0bsimho3hjyfy58f9f866 48:14.0 08:15.6 48:15.6 18:15.6 2 20 0 0x14000000010002000000FFFFFFFF0655736572496406557365724E6D100000001D000000010E557365725F316766676667666766010B66676667666866676A676AFF NULL 0

    Tuesday, March 24, 2015 4:13 AM
  • User-271186128 posted

    Hi Anuj Kathuria,

    Based on my understanding, I suggest you could create a data table in database with the following columns: SessionName, SessionData.

    When you insert data into database, you could use System.Web.Script.Serialization.JavaScriptSerializer to convert an existing object into a JSON string. And store it in to database.

    When you get data from another project, use DeserializeObject() method to get the object.

    Here is an article about ASP.NET – JSON – Serialization and Deserialization, please see: http://blogs.msdn.com/b/rakkimk/archive/2009/01/30/asp-net-json-serialization-and-deserialization.aspx

    Best Regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 27, 2015 6:18 AM