Hi.
In a program I am doing, I am trying to POST to a website. However, prior to that I have also use GET request. That is:
The error prompted is:
In a program I am doing, I am trying to POST to a website. However, prior to that I have also use GET request. That is:
VB.NET:
request = CType(WebRequest.Create("...."), HttpWebRequest)
request.Method = "GET"
request.CookieContainer = New CookieContainer()
cookie container ookie = request.CookieContainer
response = CType(request.GetResponse(), HttpWebResponse)
sr = New StreamReader(response.GetResponseStream())
'processing of sr found here, next POST to the same WebRequest created
'earlier
request.Method = "POST"
request.CookieContainer = ookie
request.ContentType = "Content-Type: application/x-www-form-urlencoded"
postData = request.GetRequestStream() ==> error occurs here
postData.Write(buffer,0,buffer.Length)
postData.Close()
Could any one please help?Unhandled Exception: System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
at System.Net.HttpWebRequest.CheckProtocol<Boolean onRequestStream>
at System.Net.HttpWebRequest.GetRequestStream()
Last edited by a moderator: