title: Using Java to login form-based authentication .NET web application
body: <p>I am trying to use Java to download a file from a form-based authentication sharepoint（as a .NET web application, but all requests are redirected to the login.aspx page. The following are the steps I use:</p>
  
  <ol>
  <li>Get the file url, and it will be redirected to login page.</li>
  <li>get all parameters from the page content;</li>
  <li>post to login.aspx page with the parameters and account &amp; password;</li>
  <li>Then Get the file and write it into a file;</li>
  </ol>
  
  <p>The steps 3 &amp; 4 are redirected to the login.aspx page. Maybe the 3rd step failed?</p>
  
  <p>PS,</p>
  
  <ul>
  <li>java tool: apache HttpClient 4.1.2</li>
  <li>Java Code:<a href="https://www.drivehq.com/folder/p9066489.aspx" rel="nofollow">https://www.drivehq.com/folder/p9066489.aspx</a> </li>
  <li>Log:<a href="https://www.drivehq.com/folder/p9066503.aspx" rel="nofollow">https://www.drivehq.com/folder/p9066503.aspx</a></li>
  </ul>