Results 1 to 4 of 4

Thread: Http problem in vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    3

    Http problem in vb.net

    dear experts
    i have w big problem, i need to solve it as soon as possible,
    i have a link to a web site i'm tying to retrieve data from it but unfortunately i have receive an error in vb " The remote server returned an error: (400) Bad Request."
    the URL work fine in the browser but i guess that hi content are dynamic or retrieved from another page, my code work fine with other URL like google.com

    so any one faced a problem like this ?


    thx you

  2. #2
    Frenzied Member joefox's Avatar
    Join Date
    Oct 2004
    Posts
    1,318

    Re: Http problem in vb.net

    You adding http:// in from of url? when you get the source?

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Http problem in vb.net

    As you haven't actually shown us what you're doing it's very difficult for us to say what you might be doing wrong.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    3

    Re: Http problem in vb.net

    Quote Originally Posted by jmcilhinney View Post
    As you haven't actually shown us what you're doing it's very difficult for us to say what you might be doing wrong.


    this is my code:



    Code:
    Dim qstr As String
    
            'qstr = "http://mylink.com"
    
            Dim HttpWReq As HttpWebRequest
            Dim HttpWResp As HttpWebResponse
            Dim streamResponse As Stream
            Dim streamRead As StreamReader
            Dim HttpWebRespStr As String
            Dim conn As System.Data.SqlClient.SqlConnection
            Dim cmd As System.Data.SqlClient.SqlCommand
            HttpWReq = CType(WebRequest.Create(qstr), HttpWebRequest)
    
            HttpWReq.KeepAlive = True
            HttpWReq.Timeout = CDbl(0.5) * 20000
            HttpWResp = CType(HttpWReq.GetResponse(), HttpWebResponse)
    
    
    
            If HttpWReq.HaveResponse Then
                streamResponse = HttpWResp.GetResponseStream()
                streamRead = New StreamReader(streamResponse)
                HttpWebRespStr = CStr(streamRead.ReadToEnd)
                streamResponse.Close()
                streamRead.Close()
                HttpWResp.Close()
                Console.WriteLine(HttpWebRespStr)
                Dim result As String = HttpWebRespStr
            End If
    when i'm using google.com i have receive page buddy but when i'm using my link no result found i got the following error: "The remote server returned an error: (406) Not Acceptable."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width