Silverlight実装セッション
6445 ワード
Silverlightはクライアントで実行されるため、sessionをシミュレートしてまずSessionManagerクラスを定義するしかありません.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
namespace WebUPGIS.controls
{
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; }
}
}
}
asp.net session silverlight
1. **.apsx?key=value silverlight sl
IDictionary<String, String> paras = HtmlPage.Document.QueryString;
if (paras.ContainsKey("userName"))
{
this.button1.Content = paras["userName"];
}
2. silverlight aspx load session hidden
session SessionManager ,
HtmlDocument document = HtmlPage.Document;
string hiddenStr = document.GetElementById("hiddenStr").GetAttribute("value");
if(hiddenStr!="")
{
string[] userInfo = hiddenStr.Split(';');
SessionManager.Session["userName"] = userInfo[0];
SessionManager.Session["userID"] = userInfo[1];
}
this.button1.Content = SessionManager.Session["userName"].ToString();
session SessionManager.Session["sessionName"]