Why is .NET Post different from CURL? broken?

Posted by ironnailpiercethesky on Stack Overflow See other posts from Stack Overflow or by ironnailpiercethesky
Published on 2010-04-22T14:25:06Z Indexed on 2010/04/22 14:33 UTC
Read the original article Hit count: 187

Filed under:
|
|
|

I dont understand this. I ran this code below and the result json string was the link is expired (meaning invalid).

However the curl code does the exact same thing and works. I either get the expected string with the url or it says i need to wait (for a few seconds to 1 minute).

Why? whats the difference between the two? It looks very F%^&*ed up that it is behaving differently (its been causing me HOURS of problems).

NOTE: the only cookie required by the site is SID (tested). It holds your session id. The first post activates it and the 2nd command checks the status with the returning json string. Feel free to set the CookieContainer to only use SID if you like.

WARNING: you may want to change SID to a different value so other people arent activating it. Your may want to run the 2nd url to ensure the session id is not used and says expired/invalid before you start.

additional note: with curl or in your browser if you do the POST command you can stick the sid in .NET cookie container and the 2nd command will work. But doing the first command (the POST data) will not work. This post function i have used for many other sites that require post and so far it has worked. Obviously checking the Method is a big deal and i see it is indeed POST when doing the first command.

    static void Main(string[] args)
    {
        var cookie = new CookieContainer();
        PostData("http://uploading.com/files/get/37e36ed8/", "action=second_page&file_id=9134949&code=37e36ed8", cookie);
        Thread.Sleep(4000);
        var res = PostData("http://uploading.com/files/get/?JsHttpRequest=12719362769080-xml&action=get_link&file_id=9134949&code=37e36ed8&pass=undefined",
            null/*this makes it GET*/, cookie);

        Console.WriteLine(res);
        /*
        curl -b "SID=37468830" -A "DUMMY_User_Aggent" -d "action=second_page&file_id=9134949&code=37e36ed8" "http://uploading.com/files/get/37e36ed8/"
        curl -b "SID=37468830" -A "DUMMY_User_Aggent" "http://uploading.com/files/get/?JsHttpRequest=12719362769080-xml&action=get_link&file_id=9134949&code=37e36ed8&pass=undefined"
        */
    }

© Stack Overflow or respective owner

Related posts about .NET

Related posts about httpwebrequest