Configuring .NET 9 Application Settings in Plesk Print

  • 0

Accessing .NET Core Settings

  1. Log in to Plesk
  2. Go to Websites & Domains
  3. Select your domain
  4. Click .NET Core or ASP.NET Core

Application Settings

Application Root

The directory containing your published .NET 9 application files.

Example: /httpdocs or /httpdocs/myapp

Document Root

The directory for static files. Usually the same as Application Root.

Application Startup File

Your main DLL file (e.g., MyWebApp.dll)

Environment Variables

Set environment variables in Plesk .NET Core settings:

Common Variables:

VariableValuePurpose
ASPNETCORE_ENVIRONMENTProductionSet app environment
ASPNETCORE_URLShttp://localhost:5000Listening URL
DOTNET_PRINT_TELEMETRY_MESSAGEfalseDisable telemetry messages

Connection Strings via Environment:

ConnectionStrings__DefaultConnection=Server=localhost;Database=mydb;User Id=user;Password=pass;TrustServerCertificate=True;

Note: Use double underscore (__) for nested configuration.

appsettings.json Configuration

Production Settings:

Create appsettings.Production.json for production-specific settings:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=mydb;..."
  },
  "AllowedHosts": "yourdomain.com"
}

Configuration Priority (highest to lowest):

  1. Environment variables (set in Plesk)
  2. appsettings.{Environment}.json
  3. appsettings.json

Logging Configuration

Enable Detailed Logging (temporarily):

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning",
      "Microsoft.EntityFrameworkCore": "Information"
    }
  }
}

View Logs in Plesk:

  1. Go to .NET Core settings
  2. Look for View Logs or stdout Logs

Kestrel Configuration

Configure Kestrel web server in appsettings.json:

{
  "Kestrel": {
    "Limits": {
      "MaxRequestBodySize": 52428800
    }
  }
}

CORS Configuration

In Program.cs:

builder.Services.AddCors(options =>
{
    options.AddDefaultPolicy(policy =>
    {
        policy.WithOrigins("https://yourdomain.com")
              .AllowAnyHeader()
              .AllowAnyMethod();
    });
});

// In middleware
app.UseCors();

Restarting Your Application

After configuration changes:

  1. Go to Websites & Domains → your domain
  2. Click .NET Core
  3. Click Restart

Troubleshooting Configuration

App Not Reading Settings:

  • Verify JSON syntax is valid
  • Check file is in publish output
  • Restart application after changes

Environment Variables Not Working:

  • Use correct format with double underscore
  • Restart application after adding
  • Check for typos in variable names

Was this answer helpful?

« Back