如何在asp.net mvc中清除cookie?

时间:2017-03-22 13:34:02

标签: c# asp.net asp.net-mvc asp.net-mvc-4 cookies

我尝试过以下操作但是,cookie在给定时间后没有过期。 你能不能查看我的代码

System.Web.HttpCookie currentUserCookie = System.Web.HttpContext.Current.Request.Cookies["Userdata"];
System.Web.HttpContext.Current.Response.Cookies.Remove("Userdata");
currentUserCookie.Expires = DateTime.Now.AddMinutes(10);

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

您需要使用Response对象写回浏览器:

usersPage

有关MSDN的更多信息:https://msdn.microsoft.com/en-us/library/ms178195.aspx

相关问题