简体   繁体   中英

Post data from C# WindowsForm to Php and update input value

I have a C# app that reads a fingerprint, converts it to a string and sends that string through post to a php website.

I'm aware that the string is being send because I get the correct response from the webserver, but it doesn't open the page or anything like that.

And what I need is this:

I have this page. And when you press the white button ("huella") it calls the C# app that reads your fingerprint

<a type="button" id="huella" href="fpp:" class="mb-xs mt-xs mr-xs btn btn-default">Huella</a>

And this WinForm app sends the converted fingerprint string via post.

    private string sendFingerprint(string fp)
    {
        try
        {
            Uri myUri = new Uri("http://localhost/demo/registrarhuella.php");
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(myUri);

            req.Method = "POST";
            string Data = "huella=" + fp;
            byte[] postBytes = Encoding.ASCII.GetBytes(Data);
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = postBytes.Length;
            Stream requestStream = req.GetRequestStream();
            requestStream.Write(postBytes, 0, postBytes.Length);
            requestStream.Close();

            HttpWebResponse response = (HttpWebResponse)req.GetResponse();
            Stream resStream = response.GetResponseStream();

            var sr = new StreamReader(response.GetResponseStream());
            string responseText = sr.ReadToEnd();
            return responseText;
        }
        catch (WebException ex)
        {

            MessageBox.Show(ex.Message.ToString());
            return null;
        }
    }

Is there a way to update the input field value of the page calling the c# app with its response? I am new and I've been having trouble finding a solution.

您无法尝试其他选择(例如不再成为开发人员)来完成此操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM