You must Sign In to post a response.
  • Category: ASP.NET

    How to pass a cookies using webservice

    Hi,

    I have webservice which should be called from C# Programming.
    While calling the webservice i need to pass a Cookies along with it.

    Kindly let me know if any coding is available for this.
  • #768534
    Hi manigandan,

    you can pass cookies using webservice like the below :


    var testWebServices = new TEST_WebServices();
    testWebServices.CookieContainer = new System.Net.CookieContainer();


    var cookie = new System.Net.Cookie("Session",sessionID.str());
    testWebServices.CookieContainer.Add(testWebServices.Url.uri() , cookie);

  • #768537
    The webservice I was call was Java Web service.
    So when I add a cookies in the header it is getting added using the below code


    Cookies.Header.Add(Cookiesvalue);


    When I call the webservices I am getting error as unauthorized. But all the rights have been given along with credentials.



    Cookies.Header.Add(Cookiesvalue);

    Cookies.DownloadFile(new uri(URL)); // Error Unauthorized 401.


    Thanks,
    Mani


  • Sign In to post your comments