vb.nethttp的简单介绍
VB.NET HttpWebRequest根据MSDN写法获取不到COOKIE,有的可以但不完整
嘿嘿,试试下面这个api
目前成都创新互联已为上千的企业提供了网站建设、域名、网页空间、网站改版维护、企业网站设计、榆次网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
Private Const INTERNET_COOKIE_HTTPONLY As Integer = H2000
SuppressUnmanagedCodeSecurity, SecurityCritical, DllImport("wininet.dll", EntryPoint:="InternetGetCookieExW", SetLastError:=True, ExactSpelling:=True)
Friend Function InternetGetCookieEx([In] Url As String, [In] cookieName As String, Out cookieData As StringBuilder, [In], Out ByRef pchCookieData As UInteger, flags As UInteger, reserved As IntPtr) As Boolean
End Function
''' summary
''' 获取webbrowser登录成功后的cookie,需要带上登录成功后的URL
''' /summary
''' param name="url"/param
''' returns/returns
SecurityCritical()
Public Function GetCookie(url As String) As String
Dim size As UInteger = 0
Dim sb As New StringBuilder
If InternetGetCookieEx(url, vbNullString, Nothing, size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero) Then '-- this always returns false
If size = 0 Then
Return Nothing
End If
sb = New StringBuilder(Convert.ToInt32(size) + 1)
If Not InternetGetCookieEx(url, vbNullString, sb, size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero) Then
Return Nothing
End If
End If
Dim lastErrorCode = Marshal.GetLastWin32Error '-- 259
Return sb.ToString()
End Function
另外,再给你一个函数
''' summary
''' 字符串型的cookie转换成cookie型的cookiecollection
''' /summary
''' param name="cookieStr"/param
''' param name="cookie"/param
''' param name="domain"/param
Public Sub StringToCookie(ByVal cookieStr As String, ByRef cookie As CookieContainer, ByVal domain As String)
cookie = New CookieContainer()
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} 转换cookie开始")
Try
Dim cookstr As String() = cookieStr.Split(";"c)
Dim cookieName As String = ""
Dim cookieValue As String = ""
For Each str As String In cookstr
cookieName = str.Substring(0, InStr(str, "=") - 1).Trim()
cookieValue = str.Substring(InStr(str, "="), str.Length - InStr(str, "=")).Trim()
Dim ck As New Cookie(cookieName, cookieValue)
'Debug.Print($"{cookieName} = {cookieValue}")
ck.Domain = domain
cookie.Add(ck)
Next
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} 转换cookie成功")
Catch ex As Exception
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} {ex.StackTrace.ToString()}")
Finally
Debug.Print($"过程:{New StackTrace().GetFrame(0).GetMethod.Name} 转换cookie结束")
End Try
End Sub
vb.net/.net怎样使用http协议的get和post?
建立ODBC数据源后,可以在Java程序中通过JDBC-ODBC接口连接数据裤:
//SQL Server
DriverManager.getConnection(''jdbc:sqlserver://主机\\实例名:端口号;
DatabaseName=数据库名'',''用户名'',''密码'')
用VB.NET 怎样通过给的HTTP地址上传文件
e As Int32 = 0 To Files.Count - 1
Dim PostedFile As HttpPostedFile = Files(iFile)
Dim FileName, FileExtent As String
FileName = Serverpath System.IO.Path.GetFileName(PostedFile.FileName)
If System.IO.Path.GetFileName(PostedFile.FileName) "" Then
FileName = System.IO.Path.GetFileName(PostedFile.FileName)
Dim Url As String = Me.Label1.Text.Trim FileName
PostedFile.SaveAs(Serve
网站题目:vb.nethttp的简单介绍
本文链接:http://azwzsj.com/article/dddgcgj.html