Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 30, 2012 07:28 AM by BU XI - MSFT
Apr 26, 2012 10:48 AM|LINK
I'd like to use ASP.NET AJAX to:
1. Put a querystring in my page (on Button1_Click) and
2. To ReWrite that querystring from "domain?country=England&city=London" to "domain/England/London/"
I don't want to Reload the whole page (i want to do it through AJAX - the scriptmanager.addhistorypoint adds to the url address without reloading the whole page).
Please advise how can i accomplish that.
p.s. I tried to use scriptmanager.addhistorypoint for that purpose, but i'm not sure that's the best choice, because of:
A) i understand it's main purpose is to support browser history, not querystrings (it also uses "#&&querystringname=variablevalue", not "?querystringnanem=variablevalue")
B) i don't know how to make url rewriting using scriptmanager.addhistorypoint.
Apr 26, 2012 12:00 PM|LINK
for url rewriting in ASP.Net 4.0, refer this
I recommend you to read the following article to understand how you can achieve partial page postback using Ajax
JQuery would be another choice using which you can load server pages.
Apr 26, 2012 05:59 PM|LINK
Please check the below reference to get Url Rewriting to work with Asp.Net Ajax:
If you take out the update panel and just do a normal post, you will see that the page will actually post directly to the unmapped url. That means your url rewriting is gone after a postback. That probably isn't what you would want, correct? If you implement
a url rewriting scheme that actually changes what the form action is, so that posts go to the mapped url instead, not only will it avoid this issue, but it will work better in general. With this scheme, you have the possibility of the server side thinking
the current request is in a different directory than the browser thinks, so things like ResolveClientUrl may report unusable paths. Any way you look at it, its best to avoid that scenario in the first place, so I recommend you take a look at the url rewriting
post by Scott Guthrie,
Apr 26, 2012 06:13 PM|LINK
I'm using HttpModule for URL rewriting like in the above topic. I implemented the version for IIS and everything works as expected.
My problem is in the process of creating URL (domain.com/name/city/category/) on Button1_Click through AJAX.
After i have a link with such URL i can read it easily through the above link URL rewriting technique.
Please, give me a small example how to do that.
p.s. I target .NET Framework 3.5, so i cannot use System.Web.Routing namespace.
Apr 27, 2012 09:51 AM|LINK
Forget about the above post in the topic, I'll try re-write my question:
To create a querystring you normaly do Response.Redirect(myurl);. When i do this in page with ASP.NET UpdatePanels, the whole page reloads, with all the UpdatePanels. If I try to do with within an UpdatePanel it behaves the same way. I want to write to the
url querystring (addressbar) without reloading the whole page. Similar to AsyncPostBackTrigger behaviour with an UpdatePanel.
The only method/approach i see doing this is the ToolkitScriptManager.AddHistoryPoint(string, string). I know this method is not designed for creating querystrings through AJAX, but rather for history points in browser. This method is using "#&&" syntax,
not "?" like in the querystring. Also, it urlencodes the whole querystring (including the slash sign "/").
Apr 30, 2012 07:28 AM|LINK
Yet it appends something after the '#', so page does not reloaded.
If you try to add something like ?, the browser then thinks it a new request, and it does send the request to the server and the page is thus reloaded. It is the browser's behaviour.
The ideal way is to provide the url like "domain/England/London/" with users in the first place, after UpdatePanel updates, rewrite it with