Net core MVC - 'HttpCookie' does not exist in 'System.Web'

Viewed 2907

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");
        }
0 Answers
Related