Avoiding having to go back twice after writing html with an onload=document.form.submit() to HttpContext.Current.Response
<p>So that's a long title, here's what I'm doing: To avoid having report parameters show up in the URL I'm doing this in a button click handler in the code-behind to show the report:</p>

<pre><code>System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Write("&lt;html&gt;&lt;head&gt;&lt;/head&gt;");    
System.Web.HttpContext.Current.Response.Write("&lt;body onload=\"document.mainform.submit(); \"&gt;");
System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "&lt;form name=\"mainform\" method=\"post\" action=\"{0}\"&gt;", ReportURL));
foreach (string key in Params.Keys)
{
    System.Web.HttpContext.Current.Response.Write(string.Format(CultureInfo.InvariantCulture, "&lt;input name=\"{0}\" type=\"hidden\" value=\"{1}\"&gt;", key, Params[key]));
}
System.Web.HttpContext.Current.Response.Write("&lt;/form&gt;");
System.Web.HttpContext.Current.Response.Write("&lt;/body&gt;&lt;/html&gt;");
</code></pre>

<p>This works great, but when I go back from the report I'm taken to the page I just generated which immediately submits the form due to the onload event. I can hit back twice really quickly to go back past it but this isn't ideal. </p>

<p>I've tried opening a new window with JavaScript using ClientScript.RegisterStartupScript before writing the html but I don't know how (or if it's even possible) to get the HttpContext for the new window.</p>

<p>Thanks for any help!</p>
