我的网站有一个asp.net按钮来发布值到外部网站,它在IE和火狐中正常工作。它重定向回Chrome的同一页。
using (WebClient client = new WebClient())
{
HttpContext.Current.Response.Write(string.Format("<body onload=document.forms[0].submit();window.location=\"{0}\";>", "Dashboard.aspx"));
HttpContext.Current.Response.Write(string.Format("<form name=\"Form\" target=_blank method=post action=\"{0}\">", URL));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"fname\" value=\"{0}\">", FirstName));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"lname\" value=\"{0}\">", LastName));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"id\" value=\"{0}\">", ID));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"tier\" value=\"{0}\">", tier));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"promo_code\" value=\"{0}\">", promoCode));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"login_key\" value=\"{0}\">", hashedKey));
HttpContext.Current.Response.Write("</form>");
HttpContext.Current.Response.Write("</body>");
}所需的行为是打开一个新的选项卡或窗口,加载外部站点,并通过POST传递参数。
当前行为只是页面刷新。这是众所周知的Chrome问题吗?我的猜测是它阻止了javascript,因为它认为它正在被“注入”。
发布于 2014-07-16 17:43:24
我猜你在发布表单和更改网址之间有一场比赛。
不需要window.location.href。提交表格就足够了。此外,您可能应该正确引用这些属性,以查看这是否有帮助。
https://stackoverflow.com/questions/24786746
复制相似问题