[英]How do I read a cookie created in jquery from code behind in vb.net?
我已经在javascript中创建了一个cookie ...
(document).ready(function () {
$.cookie("test", "Hello Michael");
alert($.cookie("test"));
});
警报按预期显示cookie内容。 我试图在后面的vb.net代码中读回它...
Dim cookie As HttpCookie
cookie = HttpContext.Current.Request.Cookies.Get("test")
If IsNothing(cookie) Then
txtCookie.Text = "Cookie not found"
Else
txtCookie.Text = cookie.Value
End If
我总是得到“找不到Cookie”。
我显然缺少了一些东西...请指教!
您需要将path
值添加到Cookie中,
$.cookie("test", "Hello Michael", { path : "/" });
并且, Request.Cookies("test")
将起作用。 另外, (document)
, $
丢失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.