如何限制用户在mvc中的一个浏览器窗口中仅练习单个会话 [英] How to limit the user to practice only single session in one browser window in mvc

查看:72
本文介绍了如何限制用户在mvc中的一个浏览器窗口中仅练习单个会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

We developing web application using MVC4 and Jquery Mobile. Recently we found one major issue which is "User using another account in same browser" so its overiding the existing account current browser. So we decided not to allow user to use two different account in one browser. We searched lot but unable to find perfect solution. So we tryed below code before login page load.

[AllowAnonymous]
        public ActionResult Index()
        {
            if (!Request.IsAuthenticated)
            {
                return View("mLogin");
            }
            else
            {
                return View("UserAlready");

             }
        }
In login controller we written this code. The login page will be shown only when user is not registered. Once he Authenticated we restrict him from loading login page again.

My question.

Is this correct method ? Is it have any drawback? Or any other better approach is there?

推荐答案

假设您正在使用表单身份验证,此方法没有主要缺点。

尝试使用在这种情况下,System.Web.HttpContext.Current.User.Identity.IsAuthenticated
Assuming you are using forms authentication, there is no major drawback in this method.
Try using System.Web.HttpContext.Current.User.Identity.IsAuthenticated in that case.


这篇关于如何限制用户在mvc中的一个浏览器窗口中仅练习单个会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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