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

我一直在试图跟随这个博客来获得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]属性应用于单个控制器,因为考虑到路由系统的工作方式,它更安全,更充分.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....