Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AspNetCore.Authorization: System.ArgumentNullException: 'Value cannot be null. (Parameter 'configure')'

I'm getting an exception while trying to run the .net 3.1 application.

public class Program
{
    public static void Main(string[] args)
    {
        var host = CreateWebHostBuilder(args).Build(); --> Exception here!

Here is the exception:

System.ArgumentNullException: 'Value cannot be null. (Parameter 'configure')'

Not sure what is the problem?

using Microsoft.AspNetCore.Authorization; (Version=5.0.0.0)
using Microsoft.AspNetCore.Mvc.Authorization;

services.AddControllers(options =>
{
    var policy = new AuthorizationPolicyBuilder()
                        .RequireAuthenticatedUser()
                        .Build();
    options.Filters.Add(new AuthorizeFilter(policy));
});
like image 737
Shahar Shokrani Avatar asked Dec 14 '22 07:12

Shahar Shokrani


1 Answers

Solved by downgrading the nuget package of Microsoft.AspNetCore.Authorization from 5.0.0 into 3.1.0 (the project is .net-core 3.1).

like image 106
Shahar Shokrani Avatar answered Dec 15 '22 20:12

Shahar Shokrani