需要 ASP.NET 核心 1.0 中的授权
Requiring authorization in ASP.NET Core 1.0
Startup.cs 中 ConfigureServices() 方法中的以下代码在我的 ASP.NET Core 1.0 RC1 项目中运行良好。现在,我正在将它迁移到最终版本,但是这一行给我一个错误,上面写着 "AuthorizationPolicyBuilder does not contain a constructor that takes that many arguments".
services.AddMvc(options =>
// Require authenticated users throughout the application
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
);
我需要对此行进行哪些修改?
其实只是一个语法错误。去掉分号:
services.AddMvc(options =>
// Require authenticated users throughout the application
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build()))
);
Startup.cs 中 ConfigureServices() 方法中的以下代码在我的 ASP.NET Core 1.0 RC1 项目中运行良好。现在,我正在将它迁移到最终版本,但是这一行给我一个错误,上面写着 "AuthorizationPolicyBuilder does not contain a constructor that takes that many arguments".
services.AddMvc(options =>
// Require authenticated users throughout the application
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
);
我需要对此行进行哪些修改?
其实只是一个语法错误。去掉分号:
services.AddMvc(options =>
// Require authenticated users throughout the application
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build()))
);