Asp.net
回發時有沒有辦法清除查詢字元串參數?
我有一個有時會與一些查詢字元串參數相關聯的表單。問題是當我回發表單時,查詢字元串參數仍然存在。我設置它的方式並不是真正的問題,但我只是不喜歡它在那裡,如果您需要按特定順序檢查輸入,可能會看到它是一個問題。
有沒有辦法以一種簡單、乾淨的方式清除該查詢字元串參數?我知道我可以更改按鈕上的 PostBackURL,但這似乎不太有效。
把它放在你的頁面底部?
<script language="javascript" type="text/javascript"> document.forms[0].action = window.location.pathname; </script>
using System.Collections; using System.Reflection;使用以下程式碼清除查詢字元串參數。
// To clear Query string value PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic); // make collection editable isreadonly.SetValue(this.Request.QueryString, false, null); // remove this.Request.QueryString.Remove("YourQueryStringParameter");