在同一页面中使用发帖方法请求和响应Web表单c#asp.net [英] Request and response web form using Post Method in same page c# asp.net

查看:85
本文介绍了在同一页面中使用发帖方法请求和响应Web表单c#asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是:我要在页面上执行发布或执行",并在同一页面上获取我已发布的页面的响应,而无需重定向或进入另一页面.

Ques : I want Post Or Execute on my page and Get Response on my same page which page i had posted without redirecting or going on another page.

我创建了一个动态Web表单.

I had created a dynamic web form.

<form id="PostForm" name="PostForm" action="https://merchant.PaymentGateway.com/thirdparties/doubleverification.htm" method="POST">
    <input type="hidden" name="merchant_code" value="XYZ">
    <input type="hidden" name="encdata" value="+yw5GSwy5ns7XP0/XYZ/6YEkdfjs fjvnsdr+cecGpm0kwhgopO3Jc9RHTld+sj7h6EKm5tcFGN8/oc5yG9E2JfXeboxlkw31bkrD4fXFr0=">
</form>

我喜欢使用C#发布Request并获得此段HTML代码的响应,而无需重定向到另一个页面上.

i like to post Request and get response this piece of HTML Code using C# without redirecting on Another Page.

我试图使用下面提到的这段代码,但它对查询字符串无效.

I was try to use this below mentioned code but its not working values for Query string.

public bool SendSMS(string mobileNo, string message)
    {
        try
        {

            string strUrl =  "https://merchant.PaymentGateway.com/thirdparties/doubleverification.htm.......... SO On...";
            WebRequest request = HttpWebRequest.Create(strUrl);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream s = response.GetResponseStream();
            StreamReader readStream = new StreamReader(s);
            string dataString = readStream.ReadToEnd();
            response.Close();
            s.Close();
            readStream.Close();

            return true;
        }
        catch (Exception)
        {
            return false;
        }
    }

如前所述,他们仅要求使用表单中的值,请尽快提出建议.

They have require Values in only Form as above mentioned with Post Method Please suggest ASAP.

推荐答案

我得到了该查询的答案.

I got Answer for This Query.

  protected void Page_Load(object sender, EventArgs e)
{
    string ForChecksum = string.Format("Sbi_txn_id={2}|arn={0}|amount={1}", "08072016012003001", "1", "1234567890");
    DoubleVerificationCheck(ForChecksum.Trim());
}

public string DoubleVerificationCheck(string data)
{
    NameValueCollection requestNameValue = new NameValueCollection();
    string postData = "encdata=" + data + "|merchant_code=XYZ";
    NameValueCollection nameValue = new NameValueCollection();
    nameValue.Add("merchant_code", "XYZ");
    nameValue.Add("encdata", data);
    string responseMsg = PostRequest("https://merchant.Payemtgateway.com/doubleverification.htm", nameValue);
   return responseMsg;

}

public static string PostRequest(string uri, NameValueCollection pairs)
{
    byte[] response = null;
    using (WebClient client = new WebClient())
    {
        response = client.UploadValues(uri, pairs);
    }
    return System.Text.Encoding.UTF8.GetString(response);
}

这篇关于在同一页面中使用发帖方法请求和响应Web表单c#asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆