简体   繁体   English

从c#codebehind更改浏览器中的URL(不是seo路由或URL重写)

[英]Change the url in browser from c# codebehind (NOT seo routing or URL rewriting)

I have a website where there is a lengthy list of items to display so I am using Pagination to make the load on server easier. 我有一个网站,其中有一个很长的项目列表,所以我使用分页来使服务器上的负载更容易。

However, I am doing the pagination via Ajax so when the user clicks on Next Page or Previous Page linkbutton, the data repeater is refreshed with ajax. 但是,我正在通过Ajax进行分页,因此当用户单击“下一页”或“上一页”链接按钮时,数据转发器将使用ajax进行刷新。

This was working fine until, people started to click on the item and then click back, it takes them to the first page. 这工作正常,直到人们开始点击该项目,然后点击返回,它将他们带到第一页。

suppose you scan about 10 pages, by clicking on the "Next Page" button. 假设您通过单击“下一页”按钮扫描大约10页。 The data changes, but the URL in the browser doesnt. 数据发生了变化,但浏览器中的URL没有。 And you think you found what you want so you click on it, the browser loads different page, and when you click back, the browser takes you to previous page but since the url did not change, you are back to page 1. 你认为你找到了你想要的东西,所以你点击它,浏览器加载不同的页面,当你点击回来时,浏览器会带你到上一页,但由于网址没有改变,你将回到第1页。

Currently, I have removed ajax so the url changes everytime, but I have seen several website re-write the url in browser when ajax even happens, and I was wondering if I could do the same. 目前,我已经删除了ajax,因此每次都会更改url,但是当ajax发生时,我已经看到几个网站在浏览器中重写了url,我想知道我是否可以这样做。

Google search for url re-write digs up only seo routing stuff, nothing on what I actually want (i am sure i am not using the right words) 谷歌搜索网址重写只挖掘seo路由的东西,没有关于我真正想要的东西(我确定我没有使用正确的词)

I was interested to know this problem, any clues or leads on this one? 我有兴趣知道这个问题,这个问题上的线索或线索是什么? thanks! 谢谢!

ps: several questions here were kind of close, but was either too complicated or too deviated. ps:这里的几个问题很接近,但要么过于复杂,要么过于偏离。 sorry if its a duplicate. 抱歉,如果它重复。

The only part of an URL that you can change in js, client-side, without forcing browser to reload whole page is an anchor part ( http://domain/page#anchor - the part after # sign). 您可以在js,客户端更改URL的唯一部分,而不强制浏览器重新加载整个页面是一个锚点部分( http://域/页#锚 - #符号后面的部分)。 This part is used by many js application (eg Google Picassa), also by silverlight to provide browser history support. 许多js应用程序(例如Google Picassa)使用此部分,也通过silverlight提供浏览器历史记录支持。 You'd have to set an anchor part when navigating to another page of your data. 导航到数据的另一页时,您必须设置锚点部分。 When the page is loaded, just check the anchor part and load appropriate page. 加载页面时,只需检查锚点部分并加载适当的页面。 Also, you'd have to periodically check for changes - this will happen when user uses back/forward feature in his/her browser. 此外,您必须定期检查更改 - 这将在用户在其浏览器中使用后退/前进功能时发生。 (There could be an event that is fired when that happens, I just haven't found it) (当发生这种情况时可能会触发一个事件,我只是没有找到它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM