Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

c# - Overriding UseAuthorization behaviour in .net core

In the asp.net core application, I want to write Authorization middleware on my own . 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"

How to add my custom method to IApplicationBuilder?In which file I need to add my method?.

Startup.cs

public void Configure(IApplicationBuilder app,IHostingenvironment env)
{
 app.UseAuthorization();
}

Example 2:

public static IApplicationBuilder UseAuthorization(this IApplicationBuilder app)
{
 return app.UseMiddleware<AuthorizationMiddleware>();
}
question from:https://stackoverflow.com/questions/66048031/overriding-useauthorization-behaviour-in-net-core

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Go the definition of your UseAuthorization to check whether you install sdk of Asp.Net Core.

enter image description here

If not, you could install and rebuild again.

Downloads for .NET Framework and .NET Core, including ASP.NET and ASP.NET Core


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...