更新时间:2023-02-14 20:11:18
离你很近了.您需要使用 Response 对象写回浏览器:
You're close. You'll need to use the Response object to write back to the browser:
if ( Request.Cookies["MyCookie"] != null )
{
var c = new HttpCookie( "MyCookie" );
c.Expires = DateTime.Now.AddDays( -1 );
Response.Cookies.Add( c );
}
有关 MSDN 的更多信息,如何:删除 Cookie.
More information on MSDN, How to: Delete a Cookie.