登录后将用户重定向回原始所需的URL [英] Redirecting user back to originally desired URL after login

查看:167
本文介绍了登录后将用户重定向回原始所需的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

  1. 用户未登录
  2. 用户购物车中有商品
  3. 用户转到/checkout
  4. 用户被重定向到/login页面
  5. 用户成功登录,应重定向回/checkout页面

在这种情况下,登录操作如何知道将用户重定向到结帐?我希望它可以在许多不同的情况下工作,而不仅仅是/checkout.

How does the login action know to redirect the user to checkout in this case? I want this to work in many different situations not just /checkout.

推荐答案

登录页面中的查询字符串参数是否足够?

Would a query string parameter in the login page be enough?

例如:www.example.com/Login.php?returnUrl=[someUrl]

eg: www.example.com/Login.php?returnUrl=[someUrl]

身份验证成功后,用户将被重定向到查询字符串中指定的url.

After the authentication is successful, the user would get redirected to the url specified in the query string.

...

这是一个常规解决方案,考虑到您所使用的框架,这不是很多选择.但是要考虑一下.

This is a general solution, it many not be an option given the framework you are using. But something to consider.

这篇关于登录后将用户重定向回原始所需的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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