4

Normally HttpCookie is part of the Namespace System.Web

Did I miss an assembly reference? And how can i add this?

The type or namespace name 'HttpCookie' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Code as Screenshot

This is a potential fix... not Show potential Fix

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");
        }
jps
  • 20,041
  • 15
  • 75
  • 79
Janneck Lange
  • 882
  • 2
  • 11
  • 34
  • 1
    HttpCookie is not part of asp.net Core... There are other ways: https://www.c-sharpcorner.com/article/asp-net-core-working-with-cookie/ – Janneck Lange Jun 05 '19 at 12:30

0 Answers0