asp.net-mvc-3 – ASP.NET MVC 3在web.config中的区域和多个身份验证

前端之家收集整理的这篇文章主要介绍了asp.net-mvc-3 – ASP.NET MVC 3在web.config中的区域和多个身份验证前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在试图跟随这个博客来获得Areas的工作:

http://mstechkb.blogspot.com/2010/10/areas-in-aspnet-mvc-20.html

博客文章中,它标识了每个区域设置身份验证的能力,例如:

@H_403_6@<location path="Area1"> <system.web> <authentication mode="Windows" /> <authorization> <allow roles="role1,role2"/> <deny users="*"/> </authorization> </system.web> </location>

但是,当我尝试在Visual Studio 2010中的一个新项目中创建它时,我运行时会收到以下错误

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

从我可以看到这是因为您不能指定身份验证元素,除非它是顶级web.config.

所以有可能做博客文章内容呢?您可以在web.config中的“位置”元素中包含认证元素区域吗?

解决方法

我学到了关于ASP.NET MVC的知识,总是比较适合将授权规则设置为[Authorization]属性应用于单个控制器,因为考虑到路由系统的工作方式,它更安全,更充分.
原文链接:https://www.f2er.com/aspnet/249862.html

猜你在找的asp.Net相关文章