【问题标题】:Post-Redirect-Get in ASP.NET在 ASP.NET 中重定向后获取
【发布时间】:2009-07-16 09:44:39
【问题描述】:

我在我的 Page1.aspx 中回发到另一个页面。如果在 Page1.aspx 中按 F5 键,则会出现消息(要再次显示网页,Internet Explorer 需要重新发送您之前提交的信息。 如果您正在购买,您应该单击取消以避免重复交易。否则,请单击重试以再次显示该网页。)

我有这个 javascript 代码,这是我的问题的解决方案??

提前致谢

function calc() 
{
    var pagoConPopup = true;

    if (pagoConPopup) 
    {
        var ventanaTPV = window.open('', 'ventanaTPV', 'width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=yes,location=yes');

        if (ventanaTPV == null || !ventanaTPV || typeof (ventanaTPV) == "undefined") 
        {
            alert("Se ha detectado bloqueador de ventanas emergentes. Desactívelo para proceder al Pago");
        }
        else 
        {
            document.forms[0].target = 'ventanaTPV';
            hacerSubmitPOST();
            ventanaTPV.focus();
        }
    }
    else 
    {
        hacerSubmitPOST();        
    }
}


function hacerSubmitPOST() 
{
    //*** Prueba de Hack ***
    //alert('Prueba de hack Amount');
    //document.getElementById("Amount").value = "12000";
    //*** Fin Prueba de Hack ***
    document.forms[0].action = '<%=strURLTpvVirtual%>';
    document.forms[0].submit();    
}

【问题讨论】:

    标签: asp.net post-redirect-get


    【解决方案1】:

    如果在重定向之后,URL 仍然显示 Page1.aspx,那么实际上重定向并没有发生,因为 URL 会更改为其他页面的 URL。发布您的服务器端代码,以便我们查看重定向应该发生的位置。

    【讨论】:

      【解决方案2】:

      button1_click 用于计算函数 javascript 的注册脚本。这个 calc 函数确实提交到另一个页面。

      protected void Button1_Click(object sender, EventArgs e) 
      { 
         strDs_Merchant_MerchantURL = Request.Params["Ds_Merchant_MerchantURL"]; 
         ... 
      
         Page.ClientScript.RegisterStartupScript(this.GetType(), "jsPagoPorTPV", 
               "<script language='JavaScript'>calc();</script>"); 
      
      } 
      

      在aspx中:

      < input type="hidden" name="Ds_Merchant_MerchantURL" value="< % =strDs_Merchant_MerchantURL% >" > 
      

      谢谢楼主。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-11
        • 1970-01-01
        • 2010-12-06
        相关资源
        最近更新 更多