Form Method post转换后面的代码。 [英] Form Method post convert code behind.

查看:68
本文介绍了Form Method post转换后面的代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有问题。



现在,我尝试在我的项目中实施支付模块。



所以他们为这样的工具发送样品。



 <%  

字符串 hashstr = clientId + oid + amount + okUrl + failUrl + islemtipi + taksit + rnd + storekey;
System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte [] hashbytes = System.Text.Encoding.GetEncoding( ISO-8859-9\" )GetBytes会(hashstr)。
byte [] inputbytes = sha.ComputeHash(hashbytes);

String hash = Convert.ToBase64String(inputbytes);


%>
< 表格 < span class =code-attribute> action
= xxxxx 方法 = POST >
< input type = 隐藏 名称 = clientid value = <% = clientId%> >
< 输入 type = 隐藏 name = amount value = <% =金额%> >

< 输入 类型 = 隐藏 名称 = oid value = <% = oid%> >
< 输入 < span class =code-attribute> type = hidden name = okUrl value = <% = okU rl%> >
< 输入 type = 隐藏 < span class =code-attribute> name = failUrl value = <% = failUrl%> >
< 输入 类型 = 隐藏 名称 = rnd value = <% = rnd%> >
< 输入 type = 隐藏 < span class =code-attribute> name = hash value = <% = hash%> < span class =code-keyword>>

< 输入 type = < span class =code-keyword> hidden name = storetype = 3d_pay_hosting >
< input type = 提交 名称 = 提交 value = 发送 >
< / form >



因此当我按下按钮时,此代码运行良好直接到银行页面,而不是在那里客户收取钱后,它返回我的okUrl。



但我的问题我必须在主页下的页面中使用此代码页面,这个网页上有很多按钮。如何很好地执行此方案。



我在网上搜索的一些代码示例说你必须像这样使用WebRequest。



 StringBuilder builderValues =  new  StringBuilder(); 
builderValues.Append( & okUrl = + http://xxx.com/Payment/ + oid);

builderValues.Append( & failUrl = + http://xxx.com/Failed/ + oid);

builderValues.Append( & storetype = 3d_pay_hosting);
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = builderValues.ToString();
// 准备网页请求...
byte [] data = new ASCIIEncoding()。GetBytes(postData);
HttpWebRequest httpWebRequest =(HttpWebRequest)WebRequest.Create( xxx);
httpWebRequest.Method = POST;
httpWebRequest.ContentType = application / x-www-form-urlencoded;
httpWebRequest.ContentLength = data.Length;
流dataStream = httpWebRequest.GetRequestStream();
dataStream.Write(data, 0 ,data.Length);
HttpWebResponse response =(HttpWebResponse)httpWebRequest.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
String responseString = reader.ReadToEnd();
dataStream.Close();





但是那段时间我的页面不会重定向到银行页面收取费用。



请给我一些帮助或建议。



谢谢。

解决方案

< blockquote>这个代码的工作原理。但现在又出现了另一个问题



 streamIn.Close(); 

会话[ deneme] = strResponse;
Response.Write(strResponse);





这个strResponse返回付费的HTML代码,但我不知道我是如何使用它的。因为我必须打开另一个页面这个html。


Hi guys I have a problem.

Now, I try to implement payment module within my project.

So they send samples for implements like this.

<%

      String hashstr = clientId + oid + amount + okUrl + failUrl + islemtipi + taksit + rnd + storekey;
      System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
      byte[] hashbytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(hashstr);
      byte[] inputbytes = sha.ComputeHash(hashbytes);

      String hash = Convert.ToBase64String(inputbytes);


  %>
  <form action="xxxxx" method="POST">
         <input type="hidden" name="clientid" value="<%=clientId%>">
              <input type="hidden" name="amount" value="<%=amount%>">

              <input type="hidden" name="oid" value="<%=oid%>">
              <input type="hidden" name="okUrl" value="<%=okUrl%>" >
              <input type="hidden" name="failUrl" value="<%=failUrl%>" >
              <input type="hidden" name="rnd" value="<%=rnd%>" >
              <input type="hidden" name="hash" value="<%=hash%>" >

              <input type="hidden" name="storetype" value="3d_pay_hosting" >
      <input type="submit" name="submit" value="Send">
  </form>


So this code run very well when I press the button my page direct to bank page and than in there customer charges the money after that it return my okUrl.

But my problem I have to use this code in page which under the master page and there are many button in this web page. How can I perform this scenario very well.

Some code samples that I search on the internet says you have to use WebRequest like this.

StringBuilder builderValues = new StringBuilder();
             builderValues.Append("&okUrl=" + "http://xxx.com/Payment/" + oid);

           builderValues.Append("&failUrl=" + "http://xxx.com/Failed/" + oid);

           builderValues.Append("&storetype=3d_pay_hosting");
           ASCIIEncoding encoding = new ASCIIEncoding();
           string postData = builderValues.ToString();
           // Prepare web request...
           byte[] data = new ASCIIEncoding().GetBytes(postData);
           HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("xxx");
           httpWebRequest.Method = "POST";
           httpWebRequest.ContentType = "application/x-www-form-urlencoded";
           httpWebRequest.ContentLength = data.Length;
           Stream dataStream = httpWebRequest.GetRequestStream();
           dataStream.Write(data, 0, data.Length);
           HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
           StreamReader reader = new StreamReader(response.GetResponseStream());
           String responseString = reader.ReadToEnd();
           dataStream.Close();



But that time my page would not redirect to bank page for charges cost.

Can you give some help or suggestion please.

Thanks.

解决方案

Guys this code worked. But now there is another problem

streamIn.Close();

            Session["deneme"] = strResponse;
            Response.Write(strResponse);



this strResponse return HTML code for payment but I don know how I use this. because I have to open another page this html.


这篇关于Form Method post转换后面的代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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