First, session runs on the server, while Silverlight runs on the client. Therefore, the session Statement in Silverlight is not accurate,
This name is only used for searching in this way.
There are two ways to associate Silverlight with Session:
Method 1: Use session in ASP. NET through WCF [because basichttpbinding does not support session in WCF, an error will be reported if a session is used]
First, add the following content under <system. servicemodel> in Web. config:
<Servicehostingenvironment aspnetcompatibilityenabled = "true"/>
Then: In the service class [Not an Interface] To add the following attributes:
[Aspnetcompatibilityrequirements (requirementsmode = aspnetcompatibilityrequirementsmode. Allowed)]
Next, you can use the session to remember to add a reference to system. Web.
Httpcontext. Current. session ["yourname"] = something;
Object something = httpcontext. Current. session ["yourname"];
Method 2: Create a static class simulation Session on the client
To save the login information, you can save the information on the client after verifying the user name and password.
Using System;
Using System. Collections. Generic;
Namespace Sessiondemo
{
Public Static Class Sessionmanager
{
Private Static Dictionary < String , Object > Session = New Dictionary < String , Object > ();
Public Static Dictionary < String , Object > Session
{
Get { Return Sessionmanager. Session ;}
Set {Sessionmanager. Session = Value ;}
}
}
}
Usage:
Assignment:
Sessionmanager. session [ " Uname " ] = " Kunal " ;< P>
value:
txbuname. text = sessionmanager. session [ " uname " ]. tostring ();
reference information: http://forums.silverlight.net/forums/t/23080.aspx