2017-02-01 103 views
0

我有C#asp.net Web窗体项目。我使用信用卡支付系统,它返回我的3d付款页面(不重定向自动)的HTML代码。这是我的要求;写动态Html内容到页面或弹出窗口

   thirdBasketItem.Price = "0.2"; 
       basketItems.Add(thirdBasketItem); 
       request.BasketItems = basketItems; 

       ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(request, options); 
       var dynamicHtml = threedsInitialize.HtmlContent; 

这里是我的dynamicHtml变量值;

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
    <title>MDpay default response template for web</title> 
</head> 
<body onload="OnLoadEvent();"> 
    <form name="downloadForm" action="https://acs.bkm.com.tr/mdpayacs/pareq" method="POST"> 
    <input type="hidden" name="PaReq" value="eJxdUl1P4zAQfOdXRHm/+KNO2yDXiEIRfeAEpXDiMefsUUskKU5ybfn1t07rc0oURd6Z8e5mduXV 
vvyI/oJtTF3NYpbQOIJK14Wp3mfxy/ruxzS+UhdyvbEAt8+gOwvqIorkAzRN/g6RKfDWeCwYz0Qa 
OwrJx+sVfB7PGJ2yK0yecEl86OkH+iJvQXHKJhQ/EZtephRf 
SXp8YFrpulbr1VvEEo78CQiKrevl+ogypxgCAys6a3EHDioTGXrhoyCA/bauAO+gVf/Pg36h0REJ 
nny3QN7cn81atzi1MR+NGJ+K1I27R87qGZwGH1PRFzRhNJL4ZFjHb50bQ7+duLjkfHP/AT7Qy6g=" /> 
    <input type="hidden" name="TermUrl" value="https://sanalpos.teb.com.tr/fim/est3Dgate?msgid=16945" /> 
    <input type="hidden" name="MD" value="402591:30D0FEDACD3047305C8E24EBC3739AC3E87C8:4273:##400644452" /> 
    <!-- To support javascript unaware/disabled browsers --> 
    <div style="text-align: center;"> 
    <img src="templates/preloader.gif" /> 
    <br /> 
    <noscript> 
    <center> 
     Please click the submit button below. 
     <br /> 
     <input type="submit" name="submit" value="Submit" /> 
    </center> 
    </noscript> 
    </div> 
    </form> 
    <script language="Javascript"> 
    function OnLoadEvent() { 
    document.downloadForm.submit(); 
    } 
</script> 
</body> 
</html> 

如何在弹出窗口或其他窗口上显示此内容以显示客户?

+0

Darn解决方案是Response.Write(dynamicHtml); – TeknobilSoft

回答

0

首先,您很可能需要清理一下html。

其次,可以呈现在web表单的HTML使用文字控制和设置HTML到Text属性.aspx页面中:

<asp:Literal ID="Literal1" 
     Mode="PassThrough" 
     Text= "Your HTML"   
     runat="server"> 
    </asp:Literal> 

下面是从MSDN的更多信息:literal control

+0

感谢您的回复,以这种方式看不到内容,但是我可以在将断点放入dynamicHtml变量并从VS2015中选择HTML Visualizer时看到它。 – TeknobilSoft

2

我想更好的解决方案是产生后重定向,我已经用3D安全支付这样做,它为我工作

NameValueCollection data = new NameValueCollection(); 

data.Add("PaReq", "eJxdUl1P4zAQfOdXRHm/+KNO2yDXiEIRfeAEpXDiMefsUUskKU5ybfn1t07rc0oURd6Z8e5mduXV 
vvyI/oJtTF3NYpbQOIJK14Wp3mfxy/ruxzS+UhdyvbEAt8+gOwvqIorkAzRN/g6RKfDWeCwYz0Qa 
OwrJx+sVfB7PGJ2yK0yecEl86OkH+iJvQXHKJhQ/EZtephRf 
SXp8YFrpulbr1VvEEo78CQiKrevl+ogypxgCAys6a3EHDioTGXrhoyCA/bauAO+gVf/Pg36h0REJ 
nny3QN7cn81atzi1MR+NGJ+K1I27R87qGZwGH1PRFzRhNJL4ZFjHb50bQ7+duLjkfHP/AT7Qy6g="); 

data.Add("TermUrl", "https://sanalpos.teb.com.tr/fim/est3Dgate?msgid=16945"); 

data.Add("MD", "402591:30D0FEDACD3047305C8E24EBC3739AC3E87C8:4273:##400644452"); 
RedirectAndPOST(this.Page, "https://acs.bkm.com.tr/mdpayacs/pareq", data); 


    /// <summary> 
    /// POST data and Redirect to the specified url using the specified page. 
    /// </summary> 
    /// <param name="page">The page which will be the referrer page.</param> 
    /// <param name="destinationUrl">The destination Url to which 
    /// the post and redirection is occuring.</param> 
    /// <param name="data">The data should be posted.</param> 
    /// <Author>Samer Abu Rabie</Author> 

    public static void RedirectAndPOST(Page page, string destinationUrl, 
             NameValueCollection data) 
    { 
     //Prepare the Posting form 
     string strForm = PreparePOSTForm(destinationUrl, data); 
     //Add a literal control the specified page holding 
     //the Post Form, this is to submit the Posting form with the request. 
     page.Controls.Add(new LiteralControl(strForm)); 
    } 

    /// <summary> 
    /// This method prepares an Html form which holds all data 
    /// in hidden field in the addetion to form submitting script. 
    /// </summary> 
    /// <param name="url">The destination Url to which the post and redirection 
    /// will occur, the Url can be in the same App or ouside the App.</param> 
    /// <param name="data">A collection of data that 
    /// will be posted to the destination Url.</param> 
    /// <returns>Returns a string representation of the Posting form.</returns> 
    /// <Author>Samer Abu Rabie</Author> 
    private static String PreparePOSTForm(string url, NameValueCollection data) 
    { 
     //Set a name for the form 
     string formID = "PostForm"; 
     //Build the form using the specified data to be posted. 
     StringBuilder strForm = new StringBuilder(); 
     strForm.Append("<form id=\"" + formID + "\" name=\"" + 
         formID + "\" action=\"" + url + 
         "\" method=\"POST\">"); 

     foreach (string key in data) 
     { 
      strForm.Append("<input type=\"hidden\" name=\"" + key + 
          "\" value=\"" + data[key] + "\">"); 
     } 

     strForm.Append("</form>"); 
     //Build the JavaScript which will do the Posting operation. 
     StringBuilder strScript = new StringBuilder(); 
     strScript.Append("<script language='javascript'>"); 
     strScript.Append("var v" + formID + " = document." + 
         formID + ";"); 
     strScript.Append("v" + formID + ".submit();"); 
     strScript.Append("</script>"); 
     //Return the form and the script concatenated. 
     //(The order is important, Form then JavaScript) 
     return strForm.ToString() + strScript.ToString(); 
    } 

https://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET

+0

感谢您的回复,在我的情况下,如何将dynamicHtml添加到NameValueCollection? – TeknobilSoft

+0

根据问题 –

+0

修改代码代替生成动态html,它直接调用URL参数 –