I have a Sharepoint onprem server side webpart and I would need to replace my query parameter without refreshing the page so I used
if (history.pushState) {
var newurl = "<%=getURL()%>" + "/SitePages/searchresults.aspx?searchtext=" + searchText;
window.history.pushState({ path: newurl }, '', newurl);
}
now this would trigger a button click, and a postback would happen which refreshes the contents of my page without reloading it. it needs to get the query string parameter from the URL. its working when i use
HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
but I am not sure if this is the correct way to do it. and I noticed that in the browser network tab, the xhr call is still the old query parameter before i changed it via pushState.
Is there a way that I can change the URL and capture it in the code behind in asp?