简体   繁体   English

刷新页面后留在同一页面

[英]Stay in the same page after refreshing the page

I have the main page: http://localhost:5111?id=12234567 (this is a cshtml page) 我有主页: http://localhost:5111?id=12234567 (这是一个cshtml页面)

there are two links: one of them send to another controller: src= controller2/index?id=1234567 有两个链接:其中一个发送到另一个控制器: src= controller2/index?id=1234567

and the seconds send to: controller3/index 并将秒发送到: controller3/index

in the index of controller2 I have another two links: one of them send to another controller: src= controller4/index?name=abcd , and the second send to: controller5/preview . controller2index ,我还有另外两个链接:其中一个发送到另一个控制器: src= controller4/index?name=abcd ,第二个发送到: controller5/preview

it doesn't matter which page I am found, the url is: http://localhost:5111?id=12234567 我找到哪个页面都没有关系,URL是: http://localhost:5111?id=12234567

so when I refresh any page, I am redirected to the main page. 因此,当我刷新任何页面时,都将重定向到主页。

I want that when I refresh a page, I will stay in the same page (will the data be saved?) 我希望当我刷新页面时,我将停留在同一页面中(是否保存数据?)

any help appreviated! 任何帮助表示赞赏!

how can I stay in the same page when I reload it? 重新加载页面后如何留在同一页面上?

Your question is irritating. 您的问题很烦人。 There is nothing like "same page" after "refreshing". “刷新”后没有类似“同一页”的内容。 Sad but true. 悲伤但真实。 Either you refresh a page, which includes a whole new HTTP-GET of a brand new exemplar of the page -in case it was not cached; 您可以刷新页面,包括页面的全新示例的全新HTTP-GET (以防未缓存); or you stay so to say on the same old one -what a waste- the server delivered. 或者您还是要说在同一台旧的服务器上-这真是浪费-交付了服务器。

What you could do is: to develop a page, whose content is updated dynamically, which means, after you retrieved "fresh" content and added that to the DOM, you stay "on the same page", meaning, your browser shows the same URL as before. 您可以做的是:开发一个页面,该页面的内容会动态更新,这意味着,在检索“新”内容并将其添加到DOM后,您将停留在“同一页面上”,这意味着浏览器显示的内容相同网址与以前一样。 But to give concrete hints, a little bit more information would be nice. 但是要给出具体提示,多一点信息将是很好的。

EDIT: Okay! 编辑:好的! The additional Information is a little bit helpful, but not quite enlightning. 额外的信息会有所帮助,但并不能为您带来启发。 As far as I can get it, you have some routing problems. 据我所知,您存在一些路由问题。 To "stay on the same page" your controller has to redirect the user after a POST to the same URL. 要“停留在同一页面上”,控制器必须在POST之后将用户重定向到相同的URL。 If you want to display the entered data, you have to use a model which contains the data entered to render the values to the page. 如果要显示输入的数据,则必须使用包含输入数据的模型以将值呈现到页面。

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

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