title: ADFS Login using WebClient returns HTML Form intsead of JSON response
body: <p>I am still in a learning phase of using web requests utilities and wanted to clarify this out. <strong>I have created a ASP.NET Web API that returns JSON response and in order to secure this, ADFS integration has been implemented.</strong></p>
  
  <p>While using WebClient I was getting the ADFS Login page as the response.So I used WebClient UploadValues to pass my Credentials with a Cookie Class.</p>
  
  <pre><code>public CookieContainer CookieContainer { get; private set; }
  
  protected override WebRequest GetWebRequest(Uri address)
  {
    var request = (HttpWebRequest)base.GetWebRequest(address);
    request.CookieContainer = CookieContainer;
    return request;
  }
  </code></pre>
  
  <p>Main.cs</p>
  
  <pre><code> using (var client = new CookieAwareWebClient())
        {
          var values = new NameValueCollection
      {
          { "username", "" },
          { "password", "" },
      };
          byte[] response=client.UploadValues(ADFS sigin url);
  </code></pre>
  
  <p><strong>The problem here is that the response i am getting is an html form with all auth details and other parameters</strong></p>
  
  <blockquote>
    <p>that says Working.. and when I copied the html response into a notepad
    and ran it inside a browser, it is redirecting me to the API url and
    giving me JSON response. How to achieve to get the JSON from Console
    Application.***</p>
  </blockquote>
  
  <p><strong>Please help on this confusion.</strong></p>