Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3224242
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:12:00+00:00 2026-05-17T16:12:00+00:00

I am trying to log into my EBay account using C#. I have looked

  • 0

I am trying to log into my EBay account using C#. I have looked at various posts and found the following 3 options. Unforunately, none of them are working. I am also listing the response header values that I get and that Fiddler shows when doing a login. There is a difference as I only get one “Set-cookie” value and Fiddler shows 10 “Set-Cookie” values. Where am I going wrong? Also, why do I only get one “Set-Cookie” value? Very grateful if anyone can share a working solution. Here are the 3 options that I tried:

        string userName = "myUserName";
        string password = "myPassword";
        string myEbayUrl = "http://my.ebay.com/ws/eBayISAPI.dll?MyEbay&gbh=1";
        string signInUrl = "https://signin.ebay.com/ws/eBayISAPI.dll? co_partnerid=2&siteid=0&UsingSSL=1";
        string postData = String.Format("MfcISAPICommand=SignInWelcome&userid={0}&pass={1}", userName, password);
        string contentType = "application/x-www-form-urlencoded";
        string method = "POST";
        string userAgent = "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)";
        string pageSource;
        CookieContainer cookieContainer = new CookieContainer();
        IWebProxy proxy = WebRequest.GetSystemWebProxy();
        proxy.Credentials = CredentialCache.DefaultCredentials;

        //OPTION 1
        Debug.WriteLine("OPTION 1:");
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(signInUrl);
        req.CookieContainer = cookieContainer;
        req.Method = method;
        req.ContentType = contentType;
        req.UserAgent = userAgent;
        req.Proxy = proxy;

        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] loginDataBytes = encoding.GetBytes(postData);
        req.ContentLength = loginDataBytes.Length;
        Stream stream = req.GetRequestStream();
        stream.Write(loginDataBytes, 0, loginDataBytes.Length);
        stream.Close();
        //login
        HttpWebResponse signInRes = (HttpWebResponse)req.GetResponse();

        //loop through header items
        foreach (var item in signInRes.Headers.AllKeys)
        {
        Debug.WriteLine(item + " : " + signInRes.Headers[item.ToString()]);
        }

        HttpWebRequest myEbayReq = (HttpWebRequest)HttpWebRequest.Create(myEbayUrl);
        myEbayReq.CookieContainer = cookieContainer;
        myEbayReq.Method = method;
        myEbayReq.ContentType = contentType;
        myEbayReq.UserAgent = userAgent;
        myEbayReq.AllowAutoRedirect = false;
        myEbayReq.Proxy = proxy;
        //get MyEbay page behind login
        using (StreamReader sr = new StreamReader(myEbayReq.GetResponse().GetResponseStream()))
        {
            pageSource = sr.ReadToEnd();
        }
        savePage(pageSource, "option1");

        //OPTION 2 without cookiecontainer
        Debug.WriteLine("OPTION 2:");
        string cookieHeader;
        WebRequest request = WebRequest.Create(signInUrl);
        request.ContentType = contentType;
        request.Method = method;
        request.Proxy = proxy;
        byte[] bytes = Encoding.ASCII.GetBytes(postData);
        request.ContentLength = bytes.Length;
        using (Stream os = request.GetRequestStream())
        {
            os.Write(bytes, 0, bytes.Length);
        }
        //login
        WebResponse loginResp = request.GetResponse();
        cookieHeader = loginResp.Headers["Set-cookie"];
        //loop through header items
        foreach (var item in loginResp.Headers.AllKeys)
        {
            Debug.WriteLine(item + " : " + loginResp.Headers[item.ToString()]);
        }
        //get MyEbay page behind login
        WebRequest getRequest = WebRequest.Create(myEbayUrl);
        getRequest.Proxy = proxy;
        getRequest.Headers.Add("Cookie", cookieHeader);
        WebResponse getResponse = getRequest.GetResponse();
        using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
        {
            pageSource = sr.ReadToEnd();
        }
        savePage(pageSource, "option2");

        //OPTION 3 using derived web client class
        Debug.WriteLine("OPTION 3:");
        using (var client = new LoginWebClient())
        {
            client.Proxy = proxy;

            var values = new NameValueCollection
            {
                { "userid", userName },
                { "pass", password },
            };
            // login
            client.UploadValues(signInUrl, values);
            //loop through header items
            foreach (var item in client.ResponseHeaders.AllKeys)
            {
                Debug.WriteLine(item +" : "+client.ResponseHeaders[item.ToString()]);
            }

            //get MyEbay page behind login
            pageSource = client.DownloadString(myEbayUrl);
        }
        savePage(pageSource,"option3");

The derived web client class:

public class LoginWebClient : WebClient
{
    public CookieContainer CookieContainer { get; private set; }

    public LoginWebClient()
    {
        CookieContainer = new CookieContainer();
    }

    protected override WebRequest GetWebRequest(Uri address)
    {
        var request = base.GetWebRequest(address);
        if (request is HttpWebRequest)
        {
            (request as HttpWebRequest).CookieContainer = CookieContainer;
        }
        return request;
    }
}

Here are the response header values I get:

OPTION 1:
Set-Cookie : ebay=%5Esbf%3D%23%5E; Domain=.ebay.com; Path=/,dp1=bpbf/%2344e96da9a^u1p/QEBfX0BAX19AQA**4e96da9a^; Domain=.ebay.com; Expires=Fri, 12-Oct-2012 12:33:30 GMT; Path=/,cssg=a594ba2b12b0a040b12546d5ffc24e56; Domain=.ebay.com; Path=/,s=CgAD4ACBMtviaYTU5NGJhMmIxMmIwYTA0MGIxMjU0NmQ1ZmZjMjRlNTblRK7X;Domain=.ebay.com;Path=/; HttpOnly,nonsession=CgADKACBWG6iaYTU5NGJhMmIxMmIwYTA0MGIxMjU0NmQ1ZmZjMjRlNTYAywABTLWuIjE5937t; Domain=.ebay.com; Expires=Thu, 13-Oct-2011 12:33:30 GMT; Path=/
Server : Apache-Coyote/1.1
Cache-Control : private
Pragma : no-cache
Content-Type : text/html;charset=UTF-8
Content-Length : 16980
Date : Wed, 13 Oct 2010 12:33:30 GMT

OPTION 2:
Set-Cookie : ebay=%5Esbf%3D%23%5E; Domain=.ebay.com; Path=/,dp1=bpbf/%2344e96da9d^u1p/QEBfX0BAX19AQA**4e96da9d^; Domain=.ebay.com; Expires=Fri, 12-Oct-2012 12:33:33 GMT; Path=/,cssg=a594c8cf12b0a02662265926ffc9c4a3; Domain=.ebay.com; Path=/,s=CgAD4ACBMtvidYTU5NGM4Y2YxMmIwYTAyNjYyMjY1OTI2ZmZjOWM0YTM4WWlH; Domain=.ebay.com; Path=/,nonsession=CgADKACBWG6idYTU5NGM4Y2YxMmIwYTAyNjYyMjY1OTI2ZmZjOWM0YTMAywABTLWuJTFk6RbF; Domain=.ebay.com; Expires=Thu, 13-Oct-2011 12:33:33 GMT; Path=/
Server : Apache-Coyote/1.1
Cache-Control : private
Pragma : no-cache
Content-Type : text/html;charset=UTF-8
Content-Length : 16979
Date : Wed, 13 Oct 2010 12:33:32 GMT

OPTION 3:
Connection : Keep-Alive
Proxy-Connection : Keep-Alive
Content-Length : 8154
Content-Type : text/html
Date : Wed, 13 Oct 2010 12:33:37 GMT
ETag : cd78002149191b683d4d0b3c98f6d5e3
Last-Modified : Wed, 13 Oct 2010 11:55:34 GMT
Server : Apache-Coyote/1.1
Via : 1.1 SATURN

And here are the response header values that Fiddler shows:

Set-Cookie: ds1=ats/1286972903913; Domain=.ebay.com; Path=/
Set-Cookie: ds2=alss/0.4cb6f76c^; Domain=.ebay.com; Path=/
Set-Cookie: ebay=%5Elrtjs%3D2.6%5EsfLMD%3D0%5Esbf%3D%23a0000000004%5Ecos%3D-7%5Ecv%3D15555%5Elvmn%3D0%7C0%7C%5Esin%3Din%5Ejs%3D1%5E; Domain=.ebay.com; Path=/
Set-Cookie: dp1=bvrvi/3%7C0%7C250707265333%7C250707988126%7C250707990497%7C4cc2d4ec^pcid/1578961514e96d96c^a1p/04cb6f76c^fm/4.3.24cdbe2b3^mpc/0%7C04cc2d4ec^pbf/%23180c20000044e96d96c^tzo/-784cb5b3fc^u1p/ZXF1aW5veDIwMTI*4e96d96c^idm/14cb83979^u1f/Ewald4e96d96c^; Domain=.ebay.com; Expires=Fri, 12-Oct-2012 12:28:28 GMT; Path=/
Set-Cookie: ns1=BAQAAASuJIxIvAAaAANgAXk6W2WxmMDAwYzg2fDYwMV4xMjg2ODg2ODY3MTQ4XmMybHlMbkp2ZEdoelkyaHBiR1E9XjFeM3wyfDY1fDV8NHw3XjFeMl40XjJeMTJeMTJeMl4xXjFeMF4xXjBeMV44MTMxAKUAGE6W2Ww2NzQ2MTc1Mi8wOzEwMjU4MTk5NjkvMDtugrDk7fid3JLf0Q9Jz19v95p6vg*;Domain=.ebay.com;Expires=Thu, 13-Oct-2011 12:28:28 GMT;Path=/; HttpOnly
Set-Cookie: cssg=a4e34c0312b0a02694e761b7fff52ae9; Domain=.ebay.com; Path=/
Set-Cookie: s=BAQAAASuJIxIvAAWAAAEAC0y292hlcXVpbm94MjAxMgASAApMtvdsdGVzdENvb2tpZQADAAVMtvdsMTYzODQA9AAiTLb3bCQyJGFQOVp0bEMzJEF3V1pTamRvVTFGYW0zdGI1aC9WZjEBRQAITpbZbDRjOTlkN2Y0AAYAAUy292wwAPgAIEy292xhNGUzNGMwMzEyYjBhMDI2OTRlNzYxYjdmZmY1MmFlOQCoAAFMtvdoMQFKABdMtvdsNGNiNWE1ZTguMC4xLjIuNDEuMS4wLjMADAAKTLb3bDEwMjU4MTk5NjkAPQALTLb3bGVxdWlub3gyMDEyAO4AwUy292wzBmh0dHA6Ly9jb2lucy5zaG9wLmViYXkuY29tL1NvdXRoLUFmcmljYS0vNDgwMjUvaS5odG1sP190cmtwYXJtcz02NSUyNTNBMTIlMjU3QzY2JTI1M0EyJTI1N0MzOSUyNTNBMSUyNTdDNzIlMjUzQTQyMDMmcnQ9bmMmX2NhdHJlZj0xJl9zdGlja3k9MSZfdHJrc2lkPXAzMjg2LmMwLm0xNCZfc29wPTEmX3NjPTEjaXRlbTNhNWY1MTQ3MzUHs3TL8cV8G9bXdjQDn2O0YlX1cH0
;Domain=.ebay.com;Path=/; HttpOnly
Set-Cookie: nonsession=BAQAAASuJIxIvAAaAABAAC06W2WxlcXVpbm94MjAxMgAzAAhOltlsNjAwMSxaQUYA8wAiTpbZbCQyJGFQOVp0bEMzJEF3V1pTamRvVTFGYW0zdGI1aC9WZjEACAAcTN0y7DEyODY5NzI3OTh4MjUwNzA3MjY1MzMzeDB4MlkAygAgVhunbDc3MzFhYjlhMTJiMGEwMjY5YTExOTlmMWZmZjk1M2I0AMsAAky1rPQxNQFMABdOltlsNGNiNWE1ZWMuMC4xLjIuNDEuMi4wLjMAnAA4TpbZbG5ZK3NIWjJQckJtZGo2d1ZuWStzRVoyUHJBMmRqNkFFa29lcENabUxwd1dkajZ4OW5ZK3NlUT09AU0AF06W2Ww0Y2I1YTVlYy4wLjEuNS40OS4wLjAuMwCdAAhOltlsMDAwMDAwMDExPLRSShRUzdDU4YsYXFXG313H7A**; Domain=.ebay.com; Expires=Thu, 13-Oct-2011 12:28:28 GMT; Path=/
Set-Cookie: secses=BAQAAASuJIxIvAAaAAUsAF06W2Ww0Y2I1YTVlYy4wLjEuMi40MS4xLjAuMxdf9sPE5nmJj5E24Fy2hCJhKoHt; Domain=.ebay.com; Path=/
Set-Cookie: lucky9=6866724; Domain=.ebay.com; Expires=Mon, 12-Oct-2015 12:28:28 GMT; Path=/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:12:01+00:00Added an answer on May 17, 2026 at 4:12 pm

    I agree with the answer about using the API. If everything you want to do is in code then this is the best way.

    However, if you’re interested in it opening a browser window, etc then I recommend using Selenium. This is aimed at web usability testing, but you can use it to open up browser windows, type into and submit form fields.

    e.g:

    var selenium = new DefaultSelenium(host,port,browserString,startUrl);
    selenium.Open("http://www.site.com");
    selenium.Type("username","myusername");
    selenium.Type("password","mypassword");
    selenium.Click("submit");
    

    Might be useful (unless you’re trying to get the headers returned, etc). Also, you can use standard XPath, etc to get an array of elements on the page and do what you need in the C# code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to log into google reader using AfNetworking AfHttpClient but I am
I am trying to log into a reports system using java. So far, I
I'm trying to log into a forum using cURL and save the cookie to
Im trying to log into Yammer using cURL. For some reason I cant get
In the middle of a webpage I am trying to log into I have
I'm trying to do the following: log into a web page (in my case
i am trying to log into my hulkshare account, and then return my account
So I am trying to log into my site using an NSMutableURLRequest which presents
I am currently trying to log into a site using Python however the site
Using Forms Authentication in ASP.NET MVC when trying to log back into a site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.