以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  用System.Net.WebRequest.Create方法如何设置cookie?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=125283)

--  作者:ap9709130
--  发布时间:2018/9/25 13:55:00
--  用System.Net.WebRequest.Create方法如何设置cookie?
如题!
--  作者:有点甜
--  发布时间:2018/9/25 14:58:00
--  

1、看看

 

http://www.foxtable.com/mobilehelp/scr/0163.htm

 

2、试试

 

Dim req = System.Net.WebRequest.Create("http://127.0.0.1")
req.Method = "get"
Dim cookieCon = new System.Net.CookieContainer
req.CookieContainer = cookieCon
Dim ck As new System.Net.Cookie("username", "123456")
req.CookieContainer.add(new Uri("http://127.0.0.1"), ck)

Dim pos = req.GetResponse()
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm,encoding.utf8)
Dim str As String = reader.ReadToEnd  
msgbox(str)
stm.Dispose()