• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

Issue Session Problem

ikosedev

New Pleskian
Server operating system version
Can't find it
Plesk version and microupdate number
Can't find it
Hello,

I've been making a project that requires logging in. But after couple of seconds, it logs out in Plesk environment. No problems in local env.
So far;
-Added SQL DataProtectionKeys API
-Modified program.cs at least 15 times, tried most of the things i could think/find online
-Changed session settings in plesk>asp.net settings>session
-Looked up for other settings in plesk panel, i think my hosting provider prohibited some of the settings
-Opened up a ticket in hosting provider website, they said they "resolved" it(no details provided), but nothing changed

This is how i check out for session;

C#:
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace CoffeeShop.Admin.Filters;

public class AdminAuthorizeAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext context)
    {
        var isLoggedIn = context.HttpContext.Session.GetString("admin");
        if (string.IsNullOrEmpty(isLoggedIn))
        {
            context.Result = new RedirectToActionResult("Login", "Auth", null);
        }
        base.OnActionExecuting(context);
    }
}

My program.cs;
C#:
using CoffeeShop.Business.Interfaces;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddDbContext<CoffeeDbContext>(options =>
    options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

builder.Services.AddScoped<ICategoryService, CategoryService>();
builder.Services.AddScoped<IProductService, ProductService>();

builder.Services.AddSession(options =>
{
    options.IdleTimeout = TimeSpan.FromHours(5);
    options.Cookie.HttpOnly = true;
    options.Cookie.IsEssential = true;
    options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
    options.Cookie.SameSite = SameSiteMode.Lax;
});
builder.WebHost.ConfigureKestrel(serverOptions =>
{
    serverOptions.AddServerHeader = false;
});

builder.Services.AddDataProtection()
    .PersistKeysToDbContext<CoffeeDbContext>();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();
app.UseAuthorization();
app.UseSession();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();
 
Okay so i contacted my hosting provider again and it seems fixed right now. This was their response, have no clue what they did.

Hello,

In order to help you and to resolve the relevant error, synchronization has been provided on the IIS side throughout the entire server.
 
Back
Top