C# httpwebrequest cookie

  • Thread starter Thread starter RCHENG
  • Start date Start date
R

RCHENG

Hi guys,

I am pretty new to network programming with c#, and is having problem
using cookie with HTTPWEBREQUEST object. My question involves sending
a request with cookie. What I am trying to do is to authenticate
myself in a browser, look at the HTTP header using a sniffer, and
simulate the http request but with different POST data. I do know what
my cookie is from the http sniffer but I can't seem to get it to put
into HTTPWEBREQUEST object.

Let's say my cookie is (it has been modified) what it is below the
dash lines.
How do I send out a HTTPWEBREQUEST with this cookie? I've looked at
CookieContainers and Cookie class but couldn't figure it out. Thanks
in advance!! =)
----------------------------------
BPTW=taishinnov15=2:; B=2a1cekh0o3640&b=2;
F=a=SEcYU.QsvWyRYtPPcaM.enG3OjSlHaH9Mz0lRzd8KcenWRy0gIgGymiGJ7WK&b=vYig;
Q=q1=AACAAAAAAAAAcw--&q2=QYZEug--;
K=kl=2eeb30h/a&kn=Ui4gQ0hFTkc-&km=Y29vbGRhckBob3RtYWlsLmNvbQ--&kp=aa1vvvsgN&ko=2eeb30h/a&kk=2eeb30h/o&kc=0;
U=mt=yQ9kd52MhYpjz81yaV8U.MIWoaJIHW_iCTIxxw--&ux=6sVmBB&un=dv5l4uiu2pccr;
T=z=NEomBABC9mBBaOy.4QFGxV3MjMxBjYzMU4zNjYxNQ--&a=4EE&sk=DAAcAt2lFnHC4D&d=c2wBTlRRMkFURTBOamswEFG1nLS0BYQE0RUUBb2sBWlcwLQF6egFORW9tQkJnV0E-;
C=mg=2; Y=v=1&n=dv5l4uiu2pccr&l=2eeb30h/o&p=m2g2ssg453830400&jb=21|34|10&r=2e&lg=us&intl=us&np=1;
MT=b.lARxeEiAGR8fCV_mwWyoCL3yj_i9CQVhs7OCzP31aDu3jCRKSGBS5UnIiDijHTvw6DWFSCdWt9.kfm8JWmTwHTdfgmEDZ9Ewi4SmBJoIJb2TRTfeGwg4zYAkV0zJzfhUd5mK8VODZruYoT.8M-
 
RCHENG,

Basically, you would create a new instance of the CookieContainer class,
adding the cookies to that. From there, you would set the CookieContainer
property on the HttpWebRequest to the CookieContainer class instance you
populated, and then send the request.

Hope this helps.
 
Back
Top