使用发布数据发布重定向到URL我正在为支付提供商做一个发布重定向,并试图将表单数据传递到他们的安全URL。我在kentico8中使用他们的自定义支付网关方法执行此操作,如下所示https://docs.kentico.com/display/K8/Creating+a+custom+payment+gateway因此,在自定义支付类中,我准备了使用本教程http://www.codeproject.com/Articles/37539/Redirect-and-POST-in将数据以带有隐藏字段的“表单”格式传递给支付提供商。-Asp-NET但是,我不知道如何使用表单数据重定向到安全的URL?到目前为止,这是我的代码。我试过Response.Redirect,但它是GET函数而不是POST。使用系统;使用系统集合;使用System.Collections.Specialized;使用系统配置;使用内容管理系统;使用CMS.Base;使用CMS.EcommerceProvider;使用CMS.Helpers;使用System.Security.Cryptography;使用System.Web;使用System.Web.Security;使用系统文本;使用System.IO;使用System.Net;使用System.Web.UI;[assembly:RegisterCustomClass("CustomGateway",typeof(CustomGateway))]publicclassCustomGateway:CMSPaymentGatewayProvider{//////处理支付。///publicoverridevoidProcessPayment(){//获取支付网关urlstringurl="https://epage.payandshop.com/epage.cgi";if(url!=""){NameValueCollectionpostData=getRealexData();RedirectAndPOST(url,postData);}else{//显示错误信息-未找到支付网关ErrorMessage="无法完成支付:未找到支付网关url。";//更新支付结果PaymentResult.PaymentDescription=ErrorMessage;付款结果.PaymentIsCompleted=假;//更新数据库中的订单支付结果UpdateOrderPaymentResult();}}publicstaticvoidRedirectAndPOST(stringdestinationUrl,NameValueCollectiondata){//准备Posting表单stringstrForm=PreparePOSTForm(destinationUrl,data);HttpContext.Current.Response.Write(strForm);HttpContext.Current.Response.End();}privatestaticStringPreparePOSTForm(stringurl,NameValueCollectiondata){//为表单设置一个名称stringformID="PostForm";//使用要发布的指定数据构建表单。StringBuilderstrForm=newStringBuilder();strForm.Append("");//构建将执行发布操作的JavaScript。StringBuilderstrScript=newStringBuilder();strScript.Append("");strScript.Append("varv"+formID+"=document."+formID+";");strScript.Append("v"+formID+".submit();");strScript.Append("");//返回表单和连接的脚本。//(顺序很重要,先是表单,然后是JavaScript)返回strForm.ToString()+strScript.ToString();}publicNameValueCollectiongetRealexData(){//格式化Realex期望的日期stringtimestamp=RealexDateFormatter.DateFormatForRealex();//从web.config中获取MerchantID和SharedSecretstringmerchantid=ConfigurationManager.AppSettings["RealexMerchantID"];stringsecret=ConfigurationManager.AppSettings["RealexSecret"];//订单信息intorderid=ShoppingCartInfoObj.OrderId;字符串stringorderid=Convert.ToString(orderid);字符串curr=ShoppingCartInfoObj.Currency.CurrencyCode;双倍金额=ShoppingCartInfoObj.TotalPrice;金额=Convert.ToInt32(金额);字符串prepareMD5=时间戳+"."+商户号+"."+orderid+"."+金额+"."+电流;//生成md5HashMD5md5=newMD5CryptoServiceProvider();字符串temp1=GetMD5Hash(prepareMD5);temp1=temp1.ToLower();字符串temp2=temp1+"."+秘密;字符串md5hash=GetMD5Hash(temp2);md5hash=md5hash.ToLower();NameValueCollection数据=newNameValueCollection();data.Add("MERCHANT_ID",merchantid);data.Add("ORDER_ID",stringorderid);data.Add("货币",当前);data.Add("金额",金额.ToString());data.Add("时间戳",时间戳);data.Add("MD5HASH",md5hash);data.Add("AUTO_SETTLE_FLAG","1");返回数据;}publicstaticStringGetMD5Hash(StringTextToHash){//检查数据是否传递if((TextToHash==null)||(TextToHash.Length==0)){returnString.Empty;}//计算MD5哈希MD5md5=newMD5CryptoServiceProvider();//创建一个新的Stringbuilder来收集字节//并创建一个字符串。byte[]data=md5.ComputeHash(Encoding.UTF8.GetBytes(TextToHash));StringBuildersBuilder=newStringBuilder();//遍历散列数据的每个字节//并将每个字节格式化为十六进制字符串。for(inti=0;i
