tags:

views:

109

answers:

4

hi..

I am very beginner With Programming...(unfortunately)

I want to remove Any added QueryString To Address after i get the variables. for example:

www.websiteName.com/page.aspx?a=344&b=233

i will get a and b and after that i want my address to look like this:

(www.websiteName.com) .

"root location".

any help...

thanks.

+2  A: 
var queryString = Request.QueryString;
// Handle querystring, then redirect to root
Response.Redirect("~/");
Response.End();

You will have to reload the page. When changing the URL, you are making another request to the server.

sshow
But then he will have to handle keeping state for the variables that were passed in, as redirect will reload the page, so, a cookie may be needed.
James Black
Thanks for replay..i will do it in PageLoad() event...i don't want to reload the page agin..
samih
You will *have* to reload the page. When changing the URL, you are making another request to the server.
sshow
i want to re-write the url address without nivgating to it!.
samih
What you want is impossible, but you could use javascript to handle parameters after a `#`-sign. This will not make another request. You can get and set these parameters using `document.location.hash`.
sshow
is that possible to use...... HttpContext.Current.RewritePath("~/");
samih
Hellow any answer......
samih
`HttpContext.Current.RewritePath()` is not made for this purpose. You can't change the url without creating a new request.
sshow
thanks sshow for helping.
samih
@samih if my post answered your question, please mark it as answered.
sshow
A: 

Why not just use

Request.UserHostName
danijels
This will get the DNS name of the remote client, not the root path of the web-site.
sshow
A: 

I wrote a blog on retrieving the URL of an ASP.Net application. Simply add the page name after the result.

This blog describes how to manipulate the query string to redirect to the same page with different (or no) parameters.

devio
thanks for replay... i want to do that without reloading the page....
samih
A: 

is there any way to use.......RewritePath("~/") function in my situation;

samih