use*_*273 3 c# asp.net asp.net-mvc
我正在做一个项目,我想做的是清除我的网址栏中的查询字符串.
但直到现在我还没多运气..
希望有人可以帮我这个..
这是我尝试做的代码之一:
System.Reflection.PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty( "IsReadOnly", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
isreadonly.SetValue(this.Request.QueryString, false, null);
this.Request.QueryString.Remove("abc");
Run Code Online (Sandbox Code Playgroud)
请求的网址无法更改.请求的URL是用户请求的,它已经发生在过去.
您可能希望在没有查询字符串的情况下将用户重定向到URL.摘自这个问题 ......
var uri = new Uri("http://www.example.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye");
string path = uri.GetLeftPart(UriPartial.Path);
return Redirect(path);
Run Code Online (Sandbox Code Playgroud)