VB.NET从POST更新Cookie
过去几天我一直在研究这个问题,终于取得了一些进展。。今天,我设法强制cookie通过请求,服务器最终验证了请求,但是我无法更新cookie并将验证后的cookie传输到接下来的几页VB.NET从POST更新Cookie,vb.net,cookies,Vb.net,Cookies,过去几天我一直在研究这个问题,终于取得了一些进展。。今天,我设法强制cookie通过请求,服务器最终验证了请求,但是我无法更新cookie并将验证后的cookie传输到接下来的几页 'post form data to page strUrl = "https://e926.net/user/authenticate" webRequest2 = HttpWebRequest.Create(strUrl) webRequest2.UserAgent = "Moz
'post form data to page
strUrl = "https://e926.net/user/authenticate"
webRequest2 = HttpWebRequest.Create(strUrl)
webRequest2.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
webRequest2.AllowAutoRedirect = True
webRequest2.Method = WebRequestMethods.Http.Post
webRequest2.ContentType = "application/x-www-form-urlencoded"
webRequest2.CookieContainer = cookies
webRequest2.ContentLength = postData.Length
requestWriter = New StreamWriter(webRequest2.GetRequestStream)
requestWriter.Write(postData)
requestWriter.Close()
Dim response2 As HttpWebResponse = CType(webRequest2.GetResponse(), HttpWebResponse)
Dim strCookies2 As String = response2.Headers("Set-Cookie")
MsgBox(strCookies2)
strCookies2 = System.Text.RegularExpressions.Regex.Split(strCookies2, "((e926=.*))")(1)
strCookies2 = strCookies2.Split(";")(0)
strCookies2 = strCookies2.Replace("e926=", "")
cookie.Name = "e926"
cookie.Value = strCookies2
cookie.Domain = ".e926.net"
cookie.HttpOnly = True
cookie.Path = "/"
cookies.Add(cookie)
'recieve authenticated cookie
webRequest2.GetResponse().Close()
这是实际提交登录详细信息并处理实际登录请求的页面代码,我可以在Fiddler中看到“用户”cookie已发送,“e926/auth”cookie已更新,但我无法从标题或我尝试过的任何其他方法获取更新的cookie
该页面是PHP,不允许“GET”请求,当然这些请求也不会有任何帮助,因为Cookie似乎从未正确传输,并且必须根据请求更新Cookie
因此,我的问题是,如何从VB.NET中的页面获取更新的cookie?我所要做的就是将“自动重定向”从“true”更改为false,并强制从“auth”页面而不是“home”页面收集cookie