我以这种方式在sharepoint webpart中保存一个cookie:
System.Web.HttpCookie cookie = new System.Web.HttpCookie(_cookieApplicationId); cookie[_cookieName] = value; cookie.Expires = DateTime.Now.AddMonths(1); HttpContext.Current.Response.SetCookie(cookie);
该cookie始终成功保存.我可以使用firebug在客户端上看到它.
当我尝试读取该cookie时:
System.Web.HttpCookie cookie = HttpContext.Current.Request.Cookies[_cookieApplicationId]; return cookie[_cookieName];