locked
MS Lightswitch - How to set session variable shared across silverlight web client and asp.net pages RRS feed

  • Question

  • I am using MS Lightswitch with Silverlight web client, also for reporting purpose I am using asp.net webforms to host crystal reports. Now I want to share some variables/data from lightswitch silverlight to asp.net webform.

    One method is to pass simple values in query string, but now I have to pass value through session. Is there any way how to do it?

    Application is hosted in IIS.


    Muhammad Idrees



    • Edited by M Idrees Sunday, November 1, 2015 8:49 AM
    Sunday, November 1, 2015 8:46 AM

Answers

  • Hi M Idrees,

    As far as I know, Session Management is not available in Silverlight. Because if we access the LightSwitch Silverlight web client, it will downloads a XAP file to client computer and runs from this file. On the other hand, Session is server side concept.

    If you want to let LightSwitch Silverlight application communicate with ASP.NET, I suggest you use WCF to implement the communication. Please use AspNetCompatibility to let WCF run in the ASP.NET Compatibility mode as being specified in the web.config:

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

    About how to use ASP.NET Sessions from WCF, please read following article. Hope it can help you.

    http://blogs.msdn.com/b/wenlong/archive/2010/02/21/using-asp-net-sessions-from-wcf.aspx

    Best Regards,
    Weiwei


    Wednesday, November 4, 2015 8:15 AM
    Moderator

All replies

  • Hi M Idrees,

    As far as I know, Session Management is not available in Silverlight. Because if we access the LightSwitch Silverlight web client, it will downloads a XAP file to client computer and runs from this file. On the other hand, Session is server side concept.

    If you want to let LightSwitch Silverlight application communicate with ASP.NET, I suggest you use WCF to implement the communication. Please use AspNetCompatibility to let WCF run in the ASP.NET Compatibility mode as being specified in the web.config:

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

    About how to use ASP.NET Sessions from WCF, please read following article. Hope it can help you.

    http://blogs.msdn.com/b/wenlong/archive/2010/02/21/using-asp-net-sessions-from-wcf.aspx

    Best Regards,
    Weiwei


    Wednesday, November 4, 2015 8:15 AM
    Moderator
  • Yes Session is server side concept.  What I was thinking, because we can access database objects from our lightswitch screens through this.DataWorkspace.ApplicationData, so I thought there would be some built-in mechanism to access session variables.

    Thanks for the tip, as you suggested I write a call to WCF service and get/set session variable by a proxy function in WCF, and it works.


    Muhammad Idrees

    Thursday, November 5, 2015 1:53 PM