在 asp.net mvc 中从 Cookie 获取错误值
getting wrong value from Cookie in asp.net mvc
我使用下面的代码添加 Cooki :
HttpCookie cookie = new HttpCookie("HozhanSecurityCode");
cookie.Value = "1234";
Response.Cookies.Add(cookie);
要获取 Cookie,请使用此代码:
var httpCookie = Request.Cookies["SecurityCode"];
string SecurityInput = httpCookie.Value.ToString();
但我得到的是“1453”而不是“1234”。
有什么问题吗?
httpcookie 构造函数中的 Cookie 名称和 Request.Cookie 对象中的键应该相同。
我使用下面的代码添加 Cooki :
HttpCookie cookie = new HttpCookie("HozhanSecurityCode");
cookie.Value = "1234";
Response.Cookies.Add(cookie);
要获取 Cookie,请使用此代码:
var httpCookie = Request.Cookies["SecurityCode"];
string SecurityInput = httpCookie.Value.ToString();
但我得到的是“1453”而不是“1234”。
有什么问题吗?
httpcookie 构造函数中的 Cookie 名称和 Request.Cookie 对象中的键应该相同。