簡體   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