Response.Redirect with POST instead of Get?

后端 未结 14 934
离开以前
离开以前 2020-11-22 04:04

We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to \"submit\" a form with POST, n

14条回答
  •  隐瞒了意图╮
    2020-11-22 04:20

    You can use this aproach:

    Response.Clear();
    
    StringBuilder sb = new StringBuilder();
    sb.Append("");
    sb.AppendFormat(@"");
    sb.AppendFormat("
    ",postbackUrl); sb.AppendFormat("", id); // Other params go here sb.Append("
    "); sb.Append(""); sb.Append(""); Response.Write(sb.ToString()); Response.End();

    As result right after client will get all html from server the event onload take place that triggers form submit and post all data to defined postbackUrl.

提交回复
热议问题