通常HttpCookie是Namespace System.Web的一部分
我错过了组装参考吗?而我该如何添加呢?
类型或名称空间名称'HttpCookie'在以下位置不存在 命名空间“ System.Web”(您是否缺少程序集引用?)
public ActionResult SetCulture(string culture)
{
// Validate input
culture = CultureHelper.GetImplementedCulture(culture);
// Save culture in a cookie
System.Web.HttpCookie cookie = Request.Cookies["_culture"];
if (cookie != null)
cookie.Value = culture; // update cookie value
else
{
cookie = new HttpCookie("_culture");
cookie.Value = culture;
cookie.Expires = DateTime.Now.AddYears(1);
}
Response.Cookies.Add(cookie);
return RedirectToAction("Index");
}