MVC3:一个控制器可以要求Windows身份验证,而第二个允许匿名? [英] MVC3: Can one controller require Windows Authentication while a second allows anonymous?

查看:134
本文介绍了MVC3:一个控制器可以要求Windows身份验证,而第二个允许匿名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器,使得在需要进行身份验证窗口内部Web应用程序页面。存在用于基于JSON的查询到那些不需要的Windows身份验证系统中的第二个控制器?那可能吗?看来我只能够做一个或其他的时刻。

I have one controller that renders pages in an internal web application that needs to be windows authenticated. There exists a second controller used for JSON-based queries into the system that do NOT need to be Windows Authenticated? Is that possible? It appears I've only been able to do one or the other at the moment.

有什么建议?

推荐答案

是的。根据你选择什么样的认证,你装饰你的控制器的操作方法Authorize

Yes. Based on what authentication you choose, you decorate your controller's action method with Authorize

本文presents你在寻找什么:
<一href=\"http://www.asp.net/mvc/tutorials/authenticating-users-with-windows-authentication-cs\">http://www.asp.net/mvc/tutorials/authenticating-users-with-windows-authentication-cs

This article presents exactly what you are looking for: http://www.asp.net/mvc/tutorials/authenticating-users-with-windows-authentication-cs

从文章的例如,清单1中的Home控制器暴露了名为Index()三个动作,CompanySecrets()和StephenSecrets()。任何人都可以调用Index()动作,但只有成员Windows本地经理组可以调用CompanySecrets()动作。最后,只有一个名为斯蒂芬(雷蒙德域)的Windows域用户可以调用StephenSecrets()动作。

这篇关于MVC3:一个控制器可以要求Windows身份验证,而第二个允许匿名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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