1:若是你想把後臺的東西傳給前臺怎麼弄?緩存
後臺:cookie
Response.Cookies.Add(new HttpCookie("UserName", HttpUtility.UrlEncode(username, System.Text.Encoding.GetEncoding("UTF-8"))));
Response.Cookies.Add(new HttpCookie("CookLoginSysId", HttpUtility.UrlEncode(loginSysId, System.Text.Encoding.GetEncoding("UTF-8"))));spa
前臺接收:code
var cookLoginSysId = decodeURI(getCookie("CookLoginSysId"));token
var userName=decodeURI(getCookie("UserName"));get
2:若是是後臺一些參數須要緩存怎麼辦?string
(1)先存入:it
HttpContext.Session["token "] = "token88888";io
HttpRuntime.Cache.Insert("RoleList", roleList);後臺
(2)獲取
string token = HttpContext.Session["token"]?.ToString();
var roleInfo =(dynamic)HttpRuntime.Cache["RoleList"];
3:若是是前臺頁面須要緩存怎麼辦?
(1)數據緩存頁:
document.cookie = "username=" +"張三";
document.cookie = "loginManufacturerInfo=" + JSON.stringify(object);
(2)數據使頁:
var username=getCookie("username");
var loginMInfoObj = eval("(" + getCookie("loginManufacturerInfo") + ")");;