开发者

Submit Page with just Code Behind Using C#

I am creating a callback page that receives info from a payment gateway and then updates a database. I then want it to 'submit' itself automatically to a 'thank you' page, passing the order number as a hidden field.

I have looked at httpwebrequest, but I can't see with this solution how it will 'post itself' if that's the right way to put it.

Any help on开发者_JAVA百科 ho to achieve this would be greatly appreciated.


If the callback page is regular ASP.NET you could do a server-side Response.Redirect or Server.Execute.

If not you can do a client-side post in javascript:

<form action="yourThankYouUrl.aspx">
    <input type="hidden" name="callbackValue" value="yourCallbackValue" />
</form>
<script type="text/javascript">
    document.forms[0].submit();
</script>


So, why not using that receive page to also show what you need and save the trouble to have one more page?

If you still want to have a 2nd page just to show the result, at the end of the processing you can write:

Session["job-id"] = "12345679";
Response.Redirect("my2ndpage.aspx");

in that 2nd Page, you simply assign the session text to the control you will have

HiddenField1.Value = Session["job-id"].ToString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜