1
クッキーの値をクッキーに保存できません。私のコードは以下の通りです:クッキーの値をクッキーに保存できません
namespace CookieCreation.Controllers
{
public class CookieController : Controller
{
// GET: /<controller>/
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult WriteCookie(String CookieName, String CookieValue, bool IsPersistent)
{
if (IsPersistent)
{
CookieOptions cookies = new CookieOptions();
cookies.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Append(CookieName, CookieValue, cookies);
}
else
{
Response.Cookies.Append(CookieName, CookieValue);
}
ViewBag.Message = ("Sucessful");
return View("Index");
}
public IActionResult ReadCookie()
{
ViewBag.CookieValue = Request.Cookies["CookieName"];
return View();
}
}
}