0

我需要退一步就這一個,並開始了......我想根據登錄的用戶通過我的視圖模型,用於加載一個組合框的值。我正在使用FA是這樣的最好的方法?我可以直接從ViewModel訪問cookie嗎?應堅持FormsAuthentication用戶遍及MVVM Silverlight應用程序

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, 
user, 
DateTime.Now, 
DateTime.Now.AddDays(30), 
false, 
"Role One", 
FormsAuthentication.FormsCookiePath); 
// Encrypt the ticket. 
string encTicket = FormsAuthentication.Encrypt(ticket); 

// Create the cookie. 
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, 
encTicket)); 
// Show the Silverlight control 
Response.Redirect("Default.aspx"); 

回答

0

答案很簡單。只需將要

string[] cookies = System.Windows.Browser.HtmlPage.Document.Cookies.Split(';'); 
參考
相關問題