2015-09-20 28 views
0

我使用Asp.net MVC 5.1.0.0和我有Admin我想在这方面使用Authentication form名称的区域,所以我加了这个Asp.net MVC 5.1.0.0和形式的认证

<system.web> 
<authentication mode="Forms"> 
    <forms loginUrl="/Admin/Account/Login" defaultUrl="/Admin/General/Index" slidingExpiration="true" timeout="20"></forms> 
</authentication> 

该地区的Web.config文件,但它给了我错误

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. 

所以我觉得这不是办法,有什么办法来为做authentication dmin区域?

回答

0

正如错误所述,表单身份验证只能在应用程序级别进行配置。这意味着您只能将<authentication>标签放在根目录web.config文件中。

是否可以对管理区域进行身份验证?

如果你只是想在管理方面使用的身份验证,那么你应该只使用类和/或动作方法的AuthorizeAttribute一个区域之内。每个人都可以访问该网站的所有其他部分。

参考:https://msdn.microsoft.com/en-us/library/ff398049(v=vs.98).aspx