[英]Overriding UseAuthorization behaviour in .net core
In the asp.net core application, I want to write Authorization middleware on my own.在asp.net核心应用中,我想自己写授权中间件。 I am trying to implement it similar to Example 2. But if I try to use I get compilation error saying " IApplicationbuilder doesnt contain a definition of UseAuthorization "
我正在尝试以类似于示例 2 的方式实现它。但如果我尝试使用,我会收到编译错误消息“ IApplicationbuilder 不包含 UseAuthorization 的定义”
How to add my custom method to IApplicationBuilder?In which file I need to add my method?.如何将我的自定义方法添加到 IApplicationBuilder?我需要在哪个文件中添加我的方法?。
Startup.cs启动.cs
public void Configure(IApplicationBuilder app,IHostingenvironment env)
{
app.UseAuthorization();
}
Example 2:示例 2:
public static IApplicationBuilder UseAuthorization(this IApplicationBuilder app)
{
return app.UseMiddleware<AuthorizationMiddleware>();
}
Go the definition of your UseAuthorization
to check whether you install sdk of Asp.Net Core. Go 定义你的
UseAuthorization
来检查你是否安装了 Asp.Net Core 的 sdk。
If not, you could install and rebuild again.如果没有,您可以重新安装和重建。
Downloads for .NET Framework and .NET Core, including ASP.NET and ASP.NET Core .NET 框架和 .NET 内核的下载,包括 ASP.NET 和 ASP.NET 内核
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.