1

嗨,我需要测试一个下载链接,我需要登录,当我尝试使用以下代码登录时,我会重定向回错误页面,因为我没有防伪令牌,你能告诉我如何获取防伪令牌,我对此很陌生,在此先感谢

//Make a post to LoginTest page
HttpWebRequest request = WebRequest.Create(loginUrlwith the login credential ) as HttpWebRequest;
request.Method = "HEAD";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

HttpWebRequest request2 = WebRequest.Create(downloadurl) as HttpWebRequest;
request2.CookieContainer = new CookieContainer();
request2.CookieContainer.Add(response.Cookies);
HttpWebResponse response2 = request2.GetResponse() as HttpWebResponse;
4

0 回答 0