Reputation: 15598
I have to create a publish-subscribe silverlight application. and the class that publishes the events is in a class library.
I have a .Net web solution which contains Silverlight project and an asp.net web project. The asp.net project uses some classes in a class library. These classes expose some events and once triggered, I get the returned data and store them in my session variables.
I have created few session variables - mainly List types.
I want to launch silverlight xaml page by redirecting the user to the aspx page which contains the silverlight plugin.
I want to use the List which are in the session variables and show them in a data grid.
Can I share the session variable between aspnet and silverlight app? What should be the best way to achieve this push-pull target that when the class throws an event, I get the data and display in a silverlight chart and the chart gets refreshed when the class publishes a new event?
Upvotes: 3
Views: 1494
Reputation: 8290
You can't share session variable between ASP.NET and Silverlight. The reason is easily understandable: ASP.NET runs serverside, Silverlight runs ClientSide.
However you can get these informations from the client, through a webservice call. Using WCF for instance, you can activate ASP.NET session for the WebService, and send in the service these informations to the client, with a proper serialization. To achieve good results, good understanding of the serialization of your session data is required (such as, with WCF, returning typed data).
For informations about activating ASP.NET session for a WCF service, see this
Keep in mind too that because default ASP.NET sessions management use cookies to store the session token client side, if your Silverlight application bypass the browser network stack, you will have to manage the cookie yourself. Fortunately, Silverlight uses the browser stack by default.
Upvotes: 2
Reputation: 16013
Please check this out "How can I access the ASP.NET session in Silverlight?"
http://forums.silverlight.net/forums/t/167001.aspx#_Toc251772491
I hope it will be helpful.
Upvotes: 1