返回 ASP.Net Core MVC 中的上一页 [英] Return to previous page in ASP.Net Core MVC

查看:44
本文介绍了返回 ASP.Net Core MVC 中的上一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的客户详细信息页面,我有一个按钮来编辑重定向到编辑页面的客户记录.我在编辑页面上有一个返回客户详细信息"链接,我想将用户重定向回上一个客户详细信息页面.

From my client detail page I have a button to edit the client record which redirects to an edit page. I have a "return to client detail" link on the edit page which I want to redirect the user back to the previous client detail page.

<a asp-controller="Client" asp-action="Detail" asp-route-id="@Model.ClientID">Return to client detail</a>

目前这按预期工作,但需要额外的时间,因为它从头开始重新加载详细信息页面(即再次运行所有各种数据库查询).由于用户实际上只是取消编辑而不更改客户端的状态,因此我希望将用户返回到上一个详细信息页面,而无需再次执行控制器操作.

Currently this works as expected but takes extra time as it reloads the detail page from scratch (ie running all the various db queries again). Since the user is really just cancelling the edit without any changes to the state of the client I am wanting to return the user to the previous detail page without having to go through the controller action again.

本质上我想模拟浏览器的后退按钮(以提高响应能力),但我不确定如何实现这一点,或者这样做是否是好的做法.一些指导将不胜感激.

Essentially I am wanting to simulate the browser back button (to improve responsiveness) but i'm not sure how to implement this or whether it's good practice to do so. Some guidance would be appreciated.

谢谢

推荐答案

您可以使用

<a href='javascript:history.go(-1)'>Return to client detail</a>

或点击

<a href="##" onClick="history.go(-1); return false;"> Return to client detail</a> 

这篇关于返回 ASP.Net Core MVC 中的上一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆