2017-06-12 98 views
0

我一直在試圖找出爲什麼我不能讓我的餅乾上顯示的網站,這裏是我的代碼:曲奇沒有出現在本地主機的網站多達

public static class UpdateCookieHelper 
{ 
    public const string COOKIE_ACCESSOR = "TurboGroup"; 

    public static void SetCookie(Group aModel) 
    { 
     HttpCookie _Cookie = new HttpCookie(COOKIE_ACCESSOR); 

     if (aModel == null) 
      _Cookie.Value = String.Empty; 
     else 
      _Cookie.Value = HttpUtility.UrlEncode(JsonConvert.SerializeObject(aModel)); 

     if (HttpContext.Current.Request.Cookies[COOKIE_ACCESSOR] == null) 
      HttpContext.Current.Response.Cookies.Add(_Cookie); 
     else 
      HttpContext.Current.Response.Cookies.Set(_Cookie); 
    } 
} 

這裏是我如何調用該函數:

UpdateCookieHelper.SetCookie(_Group); 

當我運行調試,它得到它所需要的信息,但在網站上,我看不到cookie的,所以我的getCookie()函數總是空。

任何人有想法嗎?

回答

0

答案是編碼。不需要使用JSON來完成。現在工作!

相關問題