Is there a way to clear query string parameters when posting back?
I think you've answered your own question. Use the PostBackURL property.
<asp:Button PostBackUrl='<%# Request.ServerVariables["URL"] %>' runat="server" Text="Submit" />
Or something like
foreach (Control ctrl in Page.Controls)
{
if (ctrl is Button)
{
((Button)ctrl).PostBackUrl = Request.ServerVariables["URL"];
}
}
put this at the bottom of your page?
<script language="javascript" type="text/javascript">
document.forms[0].action = window.location.pathname;
</script>
I was stuck with same issue.
I solved it using the following code block:
private void ClearQueryString()
{
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
isreadonly.SetValue(this.Request.QueryString, false, null);
this.Request.QueryString.Remove("Action");
this.Request.QueryString.Remove("param1");
this.Request.QueryString.Remove("paramN");
}
No, I haven't seen a way to clear it out without a redirect.