0

我最近尝试使用 asp.net POST 方法并提出了一些问题

当我尝试使用 post 方法时,我在问这个问题,它不允许我更改表单的操作,并且每页只允许使用一个服务器端表单。

我所做的是创建自己的表单控件并在页面上使用它

Response.Clear();

        StringBuilder sb = new StringBuilder();
        sb.Append("<html>");
        sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
        sb.AppendFormat("<form name='form' action='{0}' method='post'>", "https://test.com.au/Login/Account/Login.aspx");
        sb.AppendFormat("<input type='hidden' name='AP' value='{0}'>", "99");
        // Other params go here
        sb.Append("</form>");
        sb.Append("</body>");
        sb.Append("</html>");

        Response.Write(sb.ToString());

        Response.End();

导航到目标 URL 后,我尝试使用浏览器后退按钮,但它不起作用。只是我无法导航到后面?

这是asp.net的问题还是我错过了什么?

实际上我正在处理付款方式,它需要在 POST 方法中传递参数

4

1 回答 1

0

You try to go back, and you go back - but the previous page is automatic make "post back" and so you move to the page you are again.

So the back work, and you actually move back - what there is done is the issue of you.

The correct way is to "render" that form you show there all ready on a part of your page and with the input click of submit, you just submit that form direct, and not make a second page that make an automatic post.

I know the issue that asp.net allow only one form, but there are some alternative to that. You can read this answer that may help you: Cross-page posting. Is it a good pratice to use PreviousPage in Asp.net?

Now because you say that you make a payment getaway, the better is to fully render a page with the custom submit form, right after the form of asp.net. You actually not use the asp.net form at all and you just render your parametres, like you do above, and you let the user just click on the submit and move the the gate way.

于 2012-10-21T09:13:41.370 回答