gpt4 book ai didi

javascript - Chrome 中的 HTTP POST 自动提交

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:27:25 24 4
gpt4 key购买 nike

我正在尝试用 C# 编写一个 HttpModule,它生成一个针对特定 URL 的空 POST 请求。我使用了从另一篇文章中获得的以下代码:

HttpContext.Current.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'>", HttpContext.Current.Request.Url.ToString());
sb.AppendFormat("<input value='submit' type='submit'/>");
//sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", 1);
// Other params go here
sb.Append("</form>");
sb.Append("</body>");
sb.Append("</html>");

HttpContext.Current.Response.Write(sb.ToString());

HttpContext.Current.Response.End();

在 IE 中,这工作正常。但是,在 Chrome 中,我只看到生成的标记,几乎就像 body onload 没有正确触发一样。我错过了什么?

最佳答案

尝试设置这个值

HttpContext.Current.Response.setContentType("text/html; charset=UTF-8");

根据这个答案Html body "onload" is not working in Chrome

关于javascript - Chrome 中的 HTTP POST 自动提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35799863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com