Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I'm trying to mimic a http POST request like the one below, called by FireFox in a single frame (copied from Microsoft Network Manager)

- Http: Request, POST /popup_delete.php, Query:id=11598
    Command: POST
  - URI: /popup_delete.php?id=11598
     Location: /popup_delete.php
   - Parameters: 0x1
      id: 11598
    ProtocolVersion: HTTP/1.1
    Host:  mywebsite.com
    UserAgent:  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0
    Accept:  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language:  en-US,en;q=0.5
    Accept-Encoding:  gzip, deflate
    Referer:  http://mywebsite.com/popup_delete.php?id=11598
  - Cookie:  PHPSESSID=qq38t431qmcnb0kon93pt8u9t3; BIGipServeredms_80=307931328.20480.0000; authchallenge=8443ef4fe946eb285e0d9426f622b122
      PHPSESSID: qq38t431qmcnb0kon93pt8u9t3
      BIGipServeredms_80: 307931328.20480.0000
      authchallenge: 8443ef4fe946eb285e0d9426f622b122

    Connection:  keep-alive
  - ContentType:  application/x-www-form-urlencoded
     MediaType:  application/x-www-form-urlencoded
    ContentLength:  15
    HeaderEnd: CRLF
  - payload: HttpContentType =  application/x-www-form-urlencoded
     confirm: Confirm


so I wrote this..

C#
//CookieAwareClient inherited from WebClient. I'm using it to keep the cookie. Login is successful.
var client = new CookieAwareWebClient();
client.BaseAddress = @"http://mywebsite.com";
var loginData = new NameValueCollection();
loginData.Add("id", "myusername");
loginData.Add("password", "mypassword");
client.UploadValues("sign_in.php?", "POST", loginData);
//end login

string RouteID = "11598";
var deleteData = new NameValueCollection();
deleteData.Add("confirm", "Confirm");

string DeleteURI = string.Format("popup_delete.php?id={0}", routeID);
client.Headers.Add("Referer", string.Format("http://mywebsite.com/{0}", DeleteURI));
client.UploadValues(DeleteURI, "POST", deleteData);


resulted in this frame..

- Http: Request, POST /popup_delete.php, Query:id=11598
    Command: POST
  - URI: /popup_delete.php?id=11598
     Location: /popup_delete.php
  - Parameters: 0x1
     id: 11598
    ProtocolVersion: HTTP/1.1
  - ContentType:  application/x-www-form-urlencoded
     MediaType:  application/x-www-form-urlencoded
    Referer:  http://mywebsite.com/popup_delete.php?id=11598
    Host:  mywebsite.com
  - Cookie:  PHPSESSID=pdoev4k0gq8ddg3gvidhuqkb14; BIGipServeredms_80=307931328.20480.0000
      PHPSESSID: pdoev4k0gq8ddg3gvidhuqkb14
      BIGipServeredms_80: 307931328.20480.0000

    ContentLength:  15
    Connection:  Keep-Alive
    HeaderEnd: CRLF


and later this frame..

- Http: HTTP Payload, URL: /popup_delete.php
  - payload: HttpContentType =  application/x-www-form-urlencoded
     confirm: Confirm


In Firefox, payload was sent in the same frame but in my code, payload was sent in the next frame. I'm trying to delete an entry by mimicking what Firefox is sending. At the moment, my method is not successful.
Posted
Updated 10-Jan-13 20:34pm
v2
Comments
Sergey Alexandrovich Kryukov 11-Jan-13 0:38am    
Very good, only you did not ask any question and only told us that "method is not successful". This is not informative. Maybe just one little edit (using "Improve question", above) is needed to make it all completely clear.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900