2017-02-01 43 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參數 –