开发者

Replace the url without refreshing the page in .net

开发者 https://www.devze.com 2023-04-06 11:38 出处:网络
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.

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 r开发者_高级运维eplace the url without reloading (refreshing ) the page.

Thanks in advance


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/


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.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消