Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Webrequest and Querystring in VB.net

Webrequest and Querystring in VB.net

Scheduled Pinned Locked Moved Visual Basic
questioncsharphelp
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K king gamo

    i use the following to get it but i don think its right. < Public Sub GetNewMsg() Dim sOutput As String Dim sURL As String = "http://www.something.com/noticeboard" Try Dim objNewRequest As WebRequest = HttpWebRequest.Create(sURL) Dim objResponse As WebResponse = objNewRequest.GetResponse Dim objStream As New StreamReader(objResponse.GetResponseStream()) sOutput = objStream.ReadToEnd() Dim message_originator As String = context.request.querystring("from") Dim message As String = context.request.querystring("text") 'place code to read specific string token you need here 'for example code to insert into database etc. just see what you have in the 'string if fetch was successful and then you'll know how to readi specific string Catch eUFE As UriFormatException sOutput = "Error in URL Format: [" & sURL & "]" & NewLine() & eUFE.Message Catch eWEB As WebException sOutput = "Error With Web Request: " & NewLine() & eWEB.Message Catch e As Exception sOutput = e.ToString Finally MessageBox.Show(sOutput) End Try End Sub > Is it possible for you to write a small function that accepts data from a url into a winforms app the right way cos mine is just not working!

    It is not who i am underneath but what i do that defines me!

    modified on Friday, June 26, 2009 1:09 AM

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #4

    You're doing a post to a URL and looking for the query string on the response ? That sounds weird to me. Any change of URL is a new request/response, I'd have thought.

    Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

    K 1 Reply Last reply
    0
    • C Christian Graus

      You're doing a post to a URL and looking for the query string on the response ? That sounds weird to me. Any change of URL is a new request/response, I'd have thought.

      Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

      K Offline
      K Offline
      king gamo
      wrote on last edited by
      #5

      Christian, I am really lost in what i am doing. Please if u can help me out with retrieving from the url where i can access the query string, i will be able to continue from there. thanks

      It is not who i am underneath but what i do that defines me!

      C N 2 Replies Last reply
      0
      • K king gamo

        Christian, I am really lost in what i am doing. Please if u can help me out with retrieving from the url where i can access the query string, i will be able to continue from there. thanks

        It is not who i am underneath but what i do that defines me!

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #6

        I honestly don't think this is possible. There's nothing on the query string when you send it, so I don't expect there will ever be a querystring on the response. I think you're barking up the wrong tree.

        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

        K 1 Reply Last reply
        0
        • C Christian Graus

          I honestly don't think this is possible. There's nothing on the query string when you send it, so I don't expect there will ever be a querystring on the response. I think you're barking up the wrong tree.

          Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

          K Offline
          K Offline
          king gamo
          wrote on last edited by
          #7

          please so how do i go about retrieving the data from the url then from my winforms app?

          It is not who i am underneath but what i do that defines me!

          C 1 Reply Last reply
          0
          • K king gamo

            Christian, I am really lost in what i am doing. Please if u can help me out with retrieving from the url where i can access the query string, i will be able to continue from there. thanks

            It is not who i am underneath but what i do that defines me!

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #8

            Sounds like you are confused about request and response. You get query string only when you are getting a request. Assume you are writing a HTTP server and someone requesting to your program with query string, you will get it. In your case, you are the one who is requesting and you only get a response which won't have query strings. You will get the output of the URL you requested. Or did I got your question wrong? :)

            Navaneeth How to use google | Ask smart questions

            K 1 Reply Last reply
            0
            • N N a v a n e e t h

              Sounds like you are confused about request and response. You get query string only when you are getting a request. Assume you are writing a HTTP server and someone requesting to your program with query string, you will get it. In your case, you are the one who is requesting and you only get a response which won't have query strings. You will get the output of the URL you requested. Or did I got your question wrong? :)

              Navaneeth How to use google | Ask smart questions

              K Offline
              K Offline
              king gamo
              wrote on last edited by
              #9

              You got my question right. Now my problem is how do i get the data from the url? the winforms app has to read from the url whenever data is pushed there by a sender.

              It is not who i am underneath but what i do that defines me!

              C N 2 Replies Last reply
              0
              • K king gamo

                You got my question right. Now my problem is how do i get the data from the url? the winforms app has to read from the url whenever data is pushed there by a sender.

                It is not who i am underneath but what i do that defines me!

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #10

                We're both saying the same thing. The URL will not change, so there will be no query string data. Have you run this through the debugger ? The URL does not change, between a request and a response, which is what your code does.

                Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                K 1 Reply Last reply
                0
                • K king gamo

                  please so how do i go about retrieving the data from the url then from my winforms app?

                  It is not who i am underneath but what i do that defines me!

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #11

                  The only data on the URL, is the data you put there. This is the core issue here, which is why I said you're totally lost. What makes you think the URL will change when the data is posted back to you ?

                  Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                  1 Reply Last reply
                  0
                  • K king gamo

                    You got my question right. Now my problem is how do i get the data from the url? the winforms app has to read from the url whenever data is pushed there by a sender.

                    It is not who i am underneath but what i do that defines me!

                    N Offline
                    N Offline
                    N a v a n e e t h
                    wrote on last edited by
                    #12

                    A remote user will request a URL with some query strings. Then the page will generate some data. Now you want to get this data in your windows application. You don't know what query string he used. You don't know when user is requesting that page. Is that what you are trying to do? If yes, it is impossible. All you can do is to persist the query strings used in a database or somewhere else. Your windows application can look this DB frequently to see any new data available. If new data is there, take the query strings and send a request to the URL for getting response. :)

                    Navaneeth How to use google | Ask smart questions

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      We're both saying the same thing. The URL will not change, so there will be no query string data. Have you run this through the debugger ? The URL does not change, between a request and a response, which is what your code does.

                      Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                      K Offline
                      K Offline
                      king gamo
                      wrote on last edited by
                      #13

                      Thanks guys i get u but is there a different way i can use to achieve what i want to do please. Ok a remote server will be posting data to the url for me to read. I have setup the url like http://www.myownserver.com/noticeboard They will be pushing the data here for me to use. I dont know when the data will be available but i know the variables. 2 variables will be available for me, one for the sender and the other the text named "from","text". Is there a way out. If its impossible then i think i have to go crazy now cos i really need to do this. Is there any other way in vb that i can use or it is not possible in vb.net?

                      It is not who i am underneath but what i do that defines me!

                      C 1 Reply Last reply
                      0
                      • K king gamo

                        Thanks guys i get u but is there a different way i can use to achieve what i want to do please. Ok a remote server will be posting data to the url for me to read. I have setup the url like http://www.myownserver.com/noticeboard They will be pushing the data here for me to use. I dont know when the data will be available but i know the variables. 2 variables will be available for me, one for the sender and the other the text named "from","text". Is there a way out. If its impossible then i think i have to go crazy now cos i really need to do this. Is there any other way in vb that i can use or it is not possible in vb.net?

                        It is not who i am underneath but what i do that defines me!

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #14

                        king gamo wrote:

                        Is there any other way in vb that i can use or it is not possible in vb.net?

                        VB.NET has nothing to do with it. If you wrote the site, then push the data you want back, inside the page. Or better yet, ditch this rubbish and write a web service.

                        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups