The ASP.NET Core developer certificate is in an invalid state

While running dotnet run command you are getting the issue:

The ASP.NET Core developer certificate is in an invalid state

The solution is to execute these commands on your machine:

dotnet dev-certs https --clean
dotnet dev-certs https --trust

Accept all the prompts:

Add the following code in your project file:

  <PropertyGroup>
    <UseAppHost>false</UseAppHost>
  </PropertyGroup>

Restart the machine and run dotnet run command again, your issue will be fixed now.