我有一個身份驗證cookie,我想知道是否可以從代碼的asp.net部分中的cookie中提取數據(即在HTML部分)。我可以使用下面的代碼在後端將它拉出來從asp.net前端的cookie中提取細節
IPrincipal p = HttpContext.Current.User;
// p.Identity.Name : this is what we will use to call the stored procedure to get the data and populate it
string userid = p.Identity.Name;
Response.Write("Welcome " +
p.Identity.Name);
var dbcontext = new PrepLicensingSolution2010.DAL.LicensingEntities1();
if (userid != null)
{
var user = dbcontext.commissions_proc(userid);
}
但是這可以在前端完成嗎?
感謝
您是否在尋找JavaScript代碼? – Xaqron 2011-06-03 20:31:39
乍一看很奇怪的任務(我是關於cookies的使用)。看起來你想要人爲地解決你的問題。爲什麼你不想使用cookie?請解釋一下,什麼是源代碼問題。讓我們根據你想要實現的場景(我想<用戶類型>應該有可能<做某事>)。 – 2011-06-04 07:55:48