Get the .ASPXAUTH cookie value programmatically

后端 未结 1 1771
暗喜
暗喜 2021-01-17 02:25

Is there a way to get the .ASPXAUTH value programmatically.

Example I login to a website with my own credentials (POST) and then read the response...it does not retu

相关标签:
1条回答
  • 2021-01-17 02:43

    So the summarize the answer:

    If you're trying to login programatically on a Forms based authentication website trough your own application make sure you follow the steps you take that track the cookies.

    First create a initial GET request, and then do the subsequential POST requests that will do the postback.The request and the responses should be formulated in this way:

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url);
    request.CookieContainer = _cookieJar;
    HttpWebResponse httpsResponse = (HttpWebResponse)request.GetResponse();
    

    The CookieContainer class handles the cookies as expected.

    And if your response is encoded with Gzip just include the following line:

    request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
    

    before you call request.GetResponse()

    Hope this helps someone out there.

    0 讨论(0)
提交回复
热议问题