0

好的,我已经认输了,转而求助于可能知情的人。我在网上搜索过,尝试了一些示例,但我离从我的 cookie 容器中提取数据还差得远。

当我调试我的代码时,我可以在以下位置看到我在变量上的条目/值:CookieContianer > Non public members > m_domainTable > {domain URI} > Value > list of entries

那里有一个名为 JSESSIONID 的条目。我想做的就是获得那个特定的条目,这样我就可以使用它的分配值。

任何人都可以阐明我如何轻松解决它吗?

非常感谢。

==== 我如何提出请求的示例(注意 RequestItem 是从另一个方法传入的):

var request = (HttpWebRequest)WebRequest.Create(requestItem.RequestUri);
request.CookieContainer = new CookieContainer();

.... some additional code here building up a web request

var formResponse = (HttpWebResponse)formPost.GetResponse();

... some additional logic to check the headers to see if authentication was successful

 requestItem.CookieContainer = request.CookieContainer;

 //This call to the requested protected resource which uses the cookiecontainer from the authenticat

 var passRequest = (HttpWebResponse) requestItem.GetResponse();
4

1 回答 1

1

考虑到您的 cookie 键/值对键是JSESSIONID并且您正在尝试在ASP.NET应用程序中获取该键的值;您可以执行以下操作

var cookieValue = Request.Cookies["JSESSIONID"].Value;
于 2015-09-01T20:15:05.170 回答