Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.Net Error 403 in HTTP Web Requests
    text
    copied!<p>while using HTTP web Requests, when i try and read the stream i always get an error saying 403 Forbidden but if i try to do it in the VB.Net web browser it works fine. Here is my code:</p> <pre><code>Imports System.Net Imports System.Text Imports System.IO Public Class Form2 Dim logincookie As CookieContainer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim postData As String = "test=test&amp;username=test&amp;password=test&amp;next=test.html" Dim tempCookies As New CookieContainer Dim encoding As New UTF8Encoding Dim byteData As Byte() = encoding.GetBytes(postData) Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://test.co.uk"), HttpWebRequest) postReq.Host = "test.co.uk" postReq.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)" postReq.Method = "POST" postReq.KeepAlive = True postReq.CookieContainer = tempCookies postReq.ContentType = "application/x-www-form-urlencoded" postReq.Referer = "http://test.co.uk" postReq.ContentLength = byteData.Length Dim postreqstream As Stream = postReq.GetRequestStream() postreqstream.Write(byteData, 0, byteData.Length) postreqstream.Close() Dim postresponse As HttpWebResponse postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse) tempCookies.Add(postresponse.Cookies) logincookie = tempCookies Dim postreqreader As New StreamReader(postresponse.GetResponseStream()) Dim thepage As String = postreqreader.ReadToEnd MsgBox(thepage.ToString) End Sub End Class </code></pre> <p>Thanks, Adam</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload