2010-07-19 3 views

ответ

11
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(); 
} 
+0

Response.AppendCookie (...) был, что мне не хватало. Благодарю. –

+1

На самом деле необходимо обновить существующий файл cookie be: 'Response.SetCookie (cookie)' Response.AppendCookie просто добавляет файл cookie в коллекцию. –

Смежные вопросы