加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-15 23:00:37 所属栏目:asp.Net 来源:网络整理
导读:我一直在试图跟随这个博客来获得Areas的工作: http://mstechkb.blogspot.com/2010/10/areas-in-aspnet-mvc-20.html 在博客文章中,它标识了每个区域设置身份验证的能力,例如: location path="Area1" system.web authentication mode="Windows" / authorizat
我一直在试图跟随这个博客来获得Areas的工作:

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

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

<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]属性应用于单个控制器,因为考虑到路由系统的工作方式,它更安全,更充分.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读