By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

HttpWebRequest

P: 1
Why Return:
<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="default2.asp?CTL=C60A93E7FFFFCD87000042D692C D2D13CE752C82">here</a>.</body>

Public Function TextoURL(ByVal URL As String, Optional ByVal Post As String = "", Optional ByVal Encoding As String = "Default") As String
Try
Dim PostData() As Byte = System.Text.Encoding.ASCII.GetBytes(Post)
Dim webRequest As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URL)
Dim webResponse As System.Net.HttpWebResponse
Dim webStream As System.IO.Stream
Dim webStreamReader As System.IO.StreamReader

webRequest.AllowAutoRedirect = False
webRequest.ContentLength = PostData.Length
webRequest.ContentType = "application/x-www-form-urlencoded"
webRequest.Method = "Post"

webStream = webRequest.GetRequestStream
webStream.Write(PostData, 0, PostData.Length)

webResponse = webRequest.GetResponse
If Encoding = "Default" Then webStreamReader = New System.IO.StreamReader(webResponse.GetResponseStre am, System.Text.Encoding.Default) Else webStreamReader = New System.IO.StreamReader(webResponse.GetResponseStre am, System.Text.Encoding.GetEncoding(Encoding))

Return webStreamReader.ReadToEnd
Catch
Return ""
End Try
End Function
Jan 6 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.