简体   繁体   English

用户路由到关键区域时,ASP.NET MVC身份验证重定向到登录页面

[英]ASP.NET MVC Authentication Redirect to Login Page when user route to the critical area

I have an intranet application using windows authentication that works great. 我有一个使用Windows身份验证的Intranet应用程序,效果很好。 Now I have a requirement to expose an Admin area. 现在,我需要公开一个“管理”区域。 This area should go to login page and get user password again. 该区域应进入登录页面并再次获取用户密码。

Like when you are already logged into your Google account or your Facebook account and you need to re-enter your password when routing to a critical area. 就像您已经登录到Google帐户或Facebook帐户一样,当您路由到关键区域时需要重新输入密码。

This is an example of my application structure: 这是我的应用程序结构的一个示例:

-IntranetApp
--Controllers
--Admin Areas
----Area1
----Area2
--Special Users Area
----Area1
----Area2

Thank you very much indeed for any help/pointers. 确实非常感谢您的帮助/指标。 Now, I want to develop the mentioned code to my App using Asp.net MVC3? 现在,我想使用Asp.net MVC3将提到的代码开发到我的App中吗?

Additional information: 附加信息:

Here are a few examples: 这里有一些例子:
When you are already logged into your Google account and you want to delete your account for security reasons Google asks you to re-enter your password. 当您已经登录到Google帐户,并且出于安全原因要删除帐户时,Google会要求您重新输入密码。
Please log into your Google account, then go to Edit 2-step Verification 请登录您的Google帐户,然后转到“ 修改两步验证”

Would you mind helping me with this, please? 您能帮我解决这个问题吗?

What about using Roles? 那使用角色呢?

eg 例如

[Authorize(Roles="admin")]
public ActionResult Create() {
...
}

Guru Gu has a good post about it , from the NerdDinner application. Guru Gu在NerdDinner应用程序中有一篇很好的文章

In Asp.net MVC applications which use SQL Authentication via asp.net membership provider you can set the authentication for any controller or action by decorating it with Authorize attribute as Pure.Krome explained. 在通过asp.net成员资格提供程序使用SQL身份验证的Asp.net MVC应用程序中,您可以通过使用Pureize.Krome说明的Authorize属性装饰任何控制器或操作来设置身份验证。

But for Creating an Intranet Site Using ASP.NET MVC, I would suggest to follow this MSDN article . 但是对于使用ASP.NET MVC创建Intranet站点,我建议遵循此MSDN文章 It's a nice article explaining utilizing windows authentication 这是一篇很好的文章,解释了如何利用Windows身份验证

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

相关问题 经过身份验证的ASP.NET MVC表单身份验证时重定向用户 - redirect user when Authenticated asp.net mvc forms Authentication Asp.net Mvc 5,两个帐户控制器和一个区域,但重定向到错误的登录页面 - Asp.net Mvc 5, two account controller and Area but redirect to wrong login page 如何在 .ASP.NET Core MVC 中使用多个登录页面和未经授权的用户重定向不同的登录页面 - How to use multiple login pages in .ASP.NET Core MVC and unauthorized user redirect different login page ASP.Net MVC 5-OWIN身份验证登录重定向显示消息 - ASP.Net MVC 5 - OWIN Authentication login redirect display message 注销后,如何在ASP.NET MVC3中单击浏览器的后退按钮时将用户重定向到登录页面 - After logout,how to redirect user to login page when he/she will click back button of browser in ASP.NET MVC3 使用ASP.Net MVC中的OpenIdConnect进行身份验证后重定向用户 - Redirect user after authentication with OpenIdConnect in ASP.Net MVC 在ASP.NET MVC中使用自定义登录页面进行Intranet Windows身份验证 - intranet windows authentication with with custom login page in ASP.NET MVC 如何创建Asp.net mvc安全登录页面认证? - How to create Asp.net mvc secure login page authentication? 在 Asp.net 核心 mvc 中登录后重定向到同一页面 - Redirect to same page after Login in Asp.net core mvc ASP.NET MVC 5错误的重定向登录页面 - ASP.NET MVC 5 Wrong Redirect Login Page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM