Retrieve parameters on a web page as set by click once deployment using WebClient.UploadString(). Click once launched on same web page

24 views Asked by At

Can you retrieve the parameters from a web page as set in a click once deployment application with WebClient.UploadString()? The c sharp code below is how I send the parameters in the click once deployment application. The web page in question is the same web page that launches the click once deployment. Ideally I would like the parameters returned to the same web page. The web page is index.php. The web page is deployed on my localhost (XAMPP). When I view the contents of HtmlResult below all I see is the web page in HTML text format.

  public static string PostMessageToURL(string url, string parameters)
{
    using (WebClient wc = new WebClient())
    {
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        string HtmlResult = wc.UploadString(url,"POST", parameters);
        return HtmlResult;
    }
}

Now after some experimentation you don't use localhost or 127.0.0.1 you use your your machine name. Using the machine name works for me. This allowed the upload of the parameters. You can view your HTTP activity with fiddler. I am working on my localhost.

PostMessageToURL("http://your machine name/somesite/index.php","query=param1&query2=param2");

From the web page I tried the following JQuery code executed from the click of a button to retrieve the parameters.

    $(document).ready(function() {
       $("#Query").click(function(){
         //Retrieve parameters from server and display.
         $.get("http://localhost/somesite/index.php", function(data){
         alert("Data: " + data);
       });
    });

The above JQuery code only throws back the web page in HTML text format. No parameters.

Any help on the above much appreciated.

0

There are 0 answers