繁体   English   中英

将数据从C#WindowsForm发布到Php并更新输入值

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

我有一个C#应用程序,可以读取指纹,将其转换为字符串,然后通过邮寄将该字符串发送到php网站。

我知道该字符串正在发送,因为我从网络服务器获得了正确的响应,但是它无法打开页面或类似的东西。

我需要的是:

我有这个页面。 然后,当您按下白色按钮(“雨伞”)时,它将调用读取您的指纹的C#应用

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

并且此WinForm应用程序通过邮寄发送转换后的指纹字符串。

    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;
        }
    }

有没有一种方法可以使用其响应来更新调用c#应用程序的页面的输入字段值? 我是新手,在寻找解决方案时遇到了麻烦。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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