【问题标题】:Delete cookie on the client not working删除客户端上的 cookie 不起作用
【发布时间】:2015-07-28 10:39:27
【问题描述】:

在我的 aspx 页面的 代码隐藏 中,我创建了这个 cookie:

cookieidUserArea = new HttpCookie("idUserArea");
cookieidUserArea.Expires = DateTime.Now.AddHours(1);
cookieidUserArea.Values.Add("", idUserArea.ToString());
Response.Cookies.Add(cookieidUserArea);

在安装了这个在 asp net c# 中的应用程序的服务器上,它在 Classic ASP 3.0 中有一个页面。

如果我登录应用程序 asp net c# 并尝试在 Classic ASP 3.0 中登录页面后出现此错误:

error '80004005' 
/website/index.asp, line 15 

在这一行:

        Response.Cookies("idUserArea").Expires = Date() - 1 
        Response.Cookies("idUserArea") = ""

如果您手动删除客户端 PC 上的 cookie 并关闭并重新打开浏览器,则可以使用 Classic ASP 3.0 中的页面。

在 Classic ASP 3.0 中使用页面中的代码:

        Response.Cookies("idUserArea").Expires = Date() - 1 
        Response.Cookies("idUserArea") = ""

我尝试删除所有 cookie,但没有成功。

这是 cookie txt 文件:

idUserArea=mS10webxx.xxx.xxx/1024177534809630460199408711376030460190*

你能帮帮我吗?

提前谢谢你。

【问题讨论】:

    标签: c# asp.net cookies asp-classic


    【解决方案1】:

    您是否尝试过使用 DateTime.Now 并从中减去时间?

    https://msdn.microsoft.com/en-us/library/system.datetime.now(v=vs.110).aspx

    例如:Expires = DateTime.Now.AddHours(-1);

    【讨论】:

    • 谢谢,但问题出在经典 ASP 3.0 页面中,如果尝试您的建议,我有错误。
    • 我没有想到,因为 .NET 有 DateTime.Now 类/方法,我认为它会起作用。
    猜你喜欢
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    • 2013-02-19
    • 1970-01-01
    • 2019-06-28
    • 2011-05-08
    • 1970-01-01
    • 2014-12-02
    相关资源
    最近更新 更多