Asp.Net Core Session Not Working (Solution)

Startup.cs file in;

services.Configure<CookiePolicyOptions>(options =>
            {              
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

change to:
options.CheckConsentNeeded = context => false;

Kestrel Server Different Port with Run For Asp.Net Core (Nginx)

Create kestrel service:

nano /etc/systemd/system/kestrel-oguzhanabali.com.service
[Unit]
Description=Oguzhan ABALI Blog

[Service]
WorkingDirectory=/var/www/oguzhanabali.com
ExecStart=/usr/bin/dotnet /var/www/oguzhanabali.com/OguzhanAbali.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

Add the code below:

Environment=ASPNETCORE_URLS=http://localhost:5001

Asp.Net Core appsettings json get value in static class

Example appsettings:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AllowedHosts": "*"
}

Create MyConfig name class and;

using Microsoft.Extensions.Configuration;
static class ConfigurationManager
{
    public static IConfiguration AppSetting { get; }
    static ConfigurationManager()
    {
        AppSetting = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .Build();
    }
}

Now you can use it like :

string value = ConfigurationManager.AppSetting["value_Key"];