日期:2014-05-17  浏览次数:20393 次

【奇怪】的Cookies字符串timeStamp,是什么东西?怎样才能写到Cookie里去呢?
本帖最后由 u011321421 于 2013-10-14 23:43:34 编辑
某一网站,登录成功后,必须登录了才能访问的页面

在进入页面时要提交以下Cookie:

用Fiddle抓包看到的:

Cookie: ASP.NET_SessionId=4lfgopz3bft2hwbfr20tve55; timeStamp=1


现在我是这样设置Cookie的:
 /// 解析Cookie
        /// </summary>
        /// <param name="response"></param>
        private void ParseCookie(HttpWebResponse response)
        {
            if (!IgnoreCookies)
            {
                string cookiesExpression = response.Headers["Set-Cookie"];
                if (!string.IsNullOrEmpty(cookiesExpression))
                {
                    Uri cookieUrl = new Uri(string.Format("{0}://{1}:{2}/",
                        response.ResponseUri.Scheme,
                        response.ResponseUri.Host,
                        response.ResponseUri.Port));

                    _cookieContainer.SetCookies(cookieUrl, cookiesExpression);
                }
            }
        }


但是这样设置最终的Cookie是这个样子的:
Cookie: ASP.NET_SessionId=4lfgopz3bft2hwbfr20tve55;

导致访问网页提提示302:
HTTP/1.1 302 Found
Date: Mon, 14 Oct 2013 14:35:28 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Location: 
Cache-Control: private
Content-Type: text/html; charset=GB18030
Content-Length: 117

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href=''>here</a>.</h2>
</body></html>

【疑难】怎样才能把字符串:timeStamp=1,追加到最后呢?

参考:
Cookie.TimeStamp 属性 (System.Net)
http://msdn.microsoft.com/zh-cn/library/system.net.cookie.timestamp(VS.90).aspx