user958802
user958802

Reputation: 63

Replace the url without refreshing the page in .net

My default url home page is http://www.brindesbb.com/Pages/Default.aspx. but I dont want to show Pages/Default.aspx in the address bar.

can anyone suggest me how to replace the url without reloading (refreshing ) the page.

Thanks in advance

Upvotes: 1

Views: 3722

Answers (3)

Ad Kahn
Ad Kahn

Reputation: 579

Technically that not possible with .net as .net is used on server side. and you need to change the URL which is on client side so... you will need to use JavaScript to manipulate the Browser URL history. Example [asp.net mvc] my url is http://localhost:123/Home/Product
and I need to change it to
http://localhost:123/Home/Product/301
this can be achieved by

<script>

window.history.pushState('', 'My Page', 'Home/Product/301');

</script>

Upvotes: 0

StefanE
StefanE

Reputation: 7630

What you want to do is URL Rewriting, read more here URL Rewriting in ASP.NET

Update: If you setup a new website(or edit the one you have) and point the /Pages directory as "root" and aspx is an default document the url will be as you want.

Upvotes: 1

Issa Qandil
Issa Qandil

Reputation: 1238

You can do so in two ways IIS URL Rewriting and ASP.NET Routing

http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/

Upvotes: 1

Related Questions