Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Cookie returns null in Ajax Jquery post to MVC Core2 controller

$
0
0

hi guys
my cookie code returns null, I am trying to anonymous users activities and log to a file

Here is my code
and cookie is set as

public IActionResult Index(string key, string value, int? expireTime)
{
key = "localhost";
value = "Upload_Page";
expireTime = 10000;
CookieOptions option = new CookieOptions();

if (expireTime.HasValue)
option.Expires = DateTime.Now.AddMinutes(expireTime.Value);
else
option.Expires = DateTime.Now.AddMilliseconds(10);

Response.Cookies.Append(key, value, option);

return View();
}

string key; string value; int? expireTime;



key = Request.Cookies["key"];
value = Request.Cookies["value"];
expireTime = Int32.Parse(Request.Cookies["expireTime"]);


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>