2017-06-12 92 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来完成。现在工作!

相关问题