1

I try to set my cookie up to my website but when I write Http Cookie into the code,

my code looks like this:

HttpCookie StudentCookies = new HttpCookie("StudentCookies");
StudentCookies.Value = 1;
Response.Cookies.Add(StudentCookies);

error are:

The type or namespace name 'HttpCookie' could not be found (are you missing a using directive or an assembly reference?) TestMVCLagerSystem.DNX 4.5.1

'Response' does not contain a definition for 'Cookies' TestMVCLagerSystem.DNX 4.5.1

i have try to looke here:

Using Cookie in Asp.Net Mvc 4

Community
  • 1
  • 1
Nick Willumsen
  • 100
  • 2
  • 10

1 Answers1

1

Try using this instead:

HttpContext.Current.Response.Cookies.Add(StudentCookies);

Both HttpCookie and HttpContext belong to System.Web reference (using System.Web;)

(edited to show code formatting)

NoChinDeluxe
  • 3,446
  • 1
  • 16
  • 29