从WebRequest Cookie中提取字符串信息 [英] Extracting String Info from WebRequest Cookie
问题描述
亲爱的C#dex,
我定义一个变量:HttpWebRequest webRequest并运行以下
请求
webRequest = WebRequest.Create(TARGET_URL)as HttpWebRequest;
webRequest对象返回值,在调试器中我可以看到
我想要的物品价值
webRequest._ChallengedUri.AbsoluteUri;
但是该物业受到保护,不在
调试器。有没有人有一个建议我如何获得程序化的
访问该物业或包含
相同信息的类似公共财产?
谢谢,
James J.
***通过Developersdex发送 http://www.developersdex.com ***
不要只是参加USENET ......获得奖励!
Dear C#dex,
I define a variable: HttpWebRequest webRequest and run the following
request
webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest;
The webRequest object returns values and in the debugger I can see the
value I want in the property
webRequest._ChallengedUri.AbsoluteUri;
However that property is protected and not available outside of the
debugger. Does anyone have a suggestion how I might obtain programmatic
access to the property or a similar public property that contains the
same info?
Thanks,
James J.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!
推荐答案
你好詹姆斯:
你在找cookie值吗?您可以将CookieContainer
实例附加到您的请求中,然后遍历
Cookie对象的集合。
-
Scott
http://www.OdeToCode.com
2004年9月9日星期四07:43:40 -0700,James Johnson
< jj ****** @ hotmail.com>写道:
Hi James:
Are you looking for a cookie value? You can attach a CookieContainer
instance to your request and then iterate through the collection of
Cookie objects.
--
Scott
http://www.OdeToCode.com
On Thu, 09 Sep 2004 07:43:40 -0700, James Johnson
<jj******@hotmail.com> wrote:
亲爱的C#dex,
我定义了一个变量:HttpWebRequest webRequest并运行以下
请求>
webRequest = WebRequest.Create(TARGET_URL)作为HttpWebRequest;
webRequest对象返回值,在调试器中我可以看到我想要的属性值
>
webRequest._ChallengedUri.AbsoluteUri;
然而,该属性受到保护,并且不在
调试器之外。有没有人建议我如何获得对该物业或类似公共财产的程序性访问?
谢谢,
> James J.
***通过开发人员指南 http:// www。 developersdex.com ***
不要只是参加USENET ......获得奖励!
Dear C#dex,
I define a variable: HttpWebRequest webRequest and run the following
request
webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest;
The webRequest object returns values and in the debugger I can see the
value I want in the property
webRequest._ChallengedUri.AbsoluteUri;
However that property is protected and not available outside of the
debugger. Does anyone have a suggestion how I might obtain programmatic
access to the property or a similar public property that contains the
same info?
Thanks,
James J.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!
James Johnson写道:
James Johnson wrote:
亲爱的C#dex,
我定义了一个变量:HttpWebRequest webRequest并运行以下
请求
webRequest = WebRequest.Create(TARGET_URL)作为HttpWebRequest;
webRequest对象返回值,在调试器中我可以在属性中看到我想要的值
webRequest._ChallengedUri.AbsoluteUri;
Dear C#dex,
I define a variable: HttpWebRequest webRequest and run the following
request
webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest;
The webRequest object returns values and in the debugger I can see the
value I want in the property
webRequest._ChallengedUri.AbsoluteUri;
嗯...那里到底有什么想要的?
>
干杯,
-
Joerg Jooss
jo ********* @ gmx.net
亲爱的Joerg
物业
Dear Joerg
The property
webRequest._ChallengedUri.AbsoluteUri;
webRequest._ChallengedUri.AbsoluteUri;
包含一个uri,例如http://localhost/FirstProject/WebForm4.aspx"
我试图找出如何提取该字符串。我曾尝试过
在cookie容器中获取内容
webRequest = WebRequest.Create(TARGET_URL)作为HttpWebRequest;
webRequest .Method =" POST";
webRequest.ContentType =" application / x-www-form-urlencoded";
webRequest.CookieContainer = cookies;
//将表单值写入请求消息中
StreamWriter requestWriter = new
StreamWriter(webRequest.GetRequestStream());
requestWriter.Write(postData);
requestWriter.Close();
//我们不需要内容响应,只是cookie它
发布
webRequest.GetResponse()。关闭();
System.Net。 CookieCollection myCookieColl =
webRequest.CookieContainer.GetCookies(siteUri);
我可以在调试器中从myCookieColl获取cookie的值,但它是
被编码(例如t0m2qf55lelfzo55xsuxdi55)和myCookieColl没有暴露的
Item []属性,这使我能够通过
饼干,所以我现在卡住了。我无法弄清楚如何从该系列中获取一个
cookie,我无法弄清楚如何解码
值。
谢谢,
James J.
***通过Developersdex发送 http://www.developersdex.com ***
不要只是参加USENET ......获得奖励!
contains a uri such as "http://localhost/FirstProject/WebForm4.aspx"
I am trying to figure out how to extract that string. I have tried to
get something in a cookie container
webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest;
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.CookieContainer = cookies;
// write the form values into the request message
StreamWriter requestWriter = new
StreamWriter(webRequest.GetRequestStream());
requestWriter.Write(postData);
requestWriter.Close();
// we don''t need the contents of the response, just the cookie it
issues
webRequest.GetResponse().Close();
System.Net.CookieCollection myCookieColl =
webRequest.CookieContainer.GetCookies(siteUri);
I can get a value for a cookie from myCookieColl in the debugger, but it
is encoded (e.g. "t0m2qf55lelfzo55xsuxdi55") and there is no exposed
Item[] property for myCookieColl that would enable me to step through
the cookies, so I am stuck at present. I can''t figure out how to get a
cookie out of the collection and I can''t figure out how to decode the
Value.
Thanks,
James J.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!
这篇关于从WebRequest Cookie中提取字符串信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!