0

我正在使用 ASP Net C#。我有我在客户端更新的嵌套 cookie。我的 cookie: OwnerId=2027&LastAppId=2203&AppType=4&Mail=simba@wl js:

var cookieName = "LastAppId"
 var lastAppId = jQuery.getNestedCookie("myCookie", cookieName);
        var lastQryAppId = "&" + cookieName + "=" + lastAppId;
        var currentQryAppId = "&" + cookieName + "=" + newAppId;
        var newFullCookieStr = fullCookie.replace(lastQryAppId, currentQryAppId);
        jQuery.cookie("myCookie", newFullCookieStr, { expires: 360, path: '/' });

C#:

HttpContext.Current.Request.Cookies["myCookie"].Value ="OwnerId%3D2027%262LastAppId%3D2203%26AppType%3D4%26Mail%3Dsimba%40w.l"

但我不能按名字得到它,因为所有的钥匙都不见了。

(HttpContext.Current.Request.Cookies["2min_Auth"].Values).AllKeys[0] = null;

我知道我可以获取字符串值并将其子串化或拆分并获取值但是有人知道它为什么会发生以及如何返回键/值以再次工作?

4

1 回答 1

0
var s = HttpUtility.UrlDecode("OwnerId%3D2027%262LastAppId%3D2203%26AppType%3D4%26Mail%3Dsimba%40w.l");
NameValueCollection nameValues = HttpUtility.ParseQueryString(s);
于 2012-08-12T08:47:25.377 回答