views:

23

answers:

0

System.Net.WebException: The remote server returned an error: (404) Not Found I have three website. also have a method called post. When I post a form to siteB from siteA. the method post working perfect. When I post from siteA to siteC with same method, it give me an error System.Net.WebException: The remote server returned an error: (404) Not Found. I also use this method from my localhost to post to siteC, it also works without change anything. some ideas, Thanks. Here is the code:

Dim str As String ="varibles" Dim request As HttpWebRequest = WebRequest.Create("http:///siteC.aspx") request.KeepAlive = False request.ProtocolVersion = HttpVersion.Version10 request.Method = "POST" Dim postBytes() As Byte = Encoding.ASCII.GetBytes(str)

        ' this is important - make sure you specify type this way
        request.ContentType = "application/x-www-form-urlencoded"
        request.ContentLength = postBytes.Length
        Dim requestStream As Stream = request.GetRequestStream

        ' now send it
        requestStream.Write(postBytes, 0, postBytes.Length)
        requestStream.Close()
        'grab te response and print it out to the console along with the status code
        Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse)