C# 是否在ASP.NET MVC中更新多值cookie?

C# 是否在ASP.NET MVC中更新多值cookie?,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,如何在ASP.NET中更新多值cookie?Response.AppendCookie(…)是我缺少的。谢谢。实际上更新现有cookie应该是:Response.SetCookie(cookie)Response.AppendCookie只是将cookie添加到集合中。 public ActionResult ModifyCookie() { // Read the cookie from the request var cookie = Request.Cookies["coo

如何在ASP.NET中更新多值cookie?

Response.AppendCookie(…)是我缺少的。谢谢。实际上更新现有cookie应该是:
Response.SetCookie(cookie)
Response.AppendCookie只是将cookie添加到集合中。
public ActionResult ModifyCookie()
{
    // Read the cookie from the request
    var cookie = Request.Cookies["cookieName"];

    // Verify that the cookie was present
    if (cookie != null)
    {
        // modify a value given the key
        cookie.Values["key"] = "modified value";

        // write the modified cookie back to the response
        Response.AppendCookie(cookie);
    }
    return View();
}