[ACCEPTED]-How to remove query string parameters from the url?-query-string
Request.Querystring is read-only collection - You cannot modify that.
If you need to 6 remove or change the param in querystring 5 only way out is to trigger a new GET request 4 with updated querystring - This means you 3 will have to do Response.Redirect with updated 2 URL. This will cause you lose the viewstate 1 of the current page.
Use the PostBackUrl property, for example:
<asp:Button ID="DoneEditingButton" runat="server" Text="Done editing" PostBackUrl="~/two.aspx" />
0
When you are done with the edit you are 4 doing a post back so just define the action 3 to post to two.aspx instead of just posting 2 back to itself that way it will drop off 1 the get parameters.
How about checking Page.IsPostBack to see 2 if the current request is a postback or 1 not?
if you have only string, you can use:
strinULR.Split('?').First();
or 1
strinULR.Split('?').FirstOrDefault();
Try something like this.
if (url.Contains("?"))
url = url.Substring(0, url.IndexOf("?"));
In this example, I'm 4 checking if the url even contains a query 3 string, and if it does, subtracting getting 2 the "left part" of the string prior to the 1 ?.
Late but you can do this to remove query 1 string from URL without another GET Request. http://www.codeproject.com/Tips/177679/Removing-Deleting-Querystring-in-ASP-NET
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.