Skip to content

Deploy ASP.NET website ​

Website configuration ​

Suppose you have an ASP.NET website that you want to run under the domain domain.com

  1. Go to application store, install the ASP.NET application

  2. Create a website with the following configuration

    • Enter domain
    • Select Proxy Port
    • Enter the port your ASP.NET application runs on, for example 3000
  3. Install the source code for the website from git or upload it yourself

  4. Update Database & Build & Publish

    Open the terminal for the website

    bash
    dotnet ef database update
    dotnet build
    dotnet publish
  5. Create Service for website

    Use the Service management feature to create a service

    Create a service named domain_com (you can put domain_com or whatever you want, but note that it is short, easy to remember, no special characters)

    You can refer to the content of domain_com below

    ini
    [Unit]
    Description=ASP.NET - domain.com
    
    [Service]
    WorkingDirectory=/home/{{ data.linux_user }}/domain.com // [!code focus]
    ExecStart=/usr/bin/dotnet /home/{{ data.linux_user }}/domain.com/bin/Debug/netcoreapp8.0/publish/domain_com.dll --urls "http://127.0.0.1:3000" // [!code focus ]
    Restart=always
    RestartSec=10
    KillSignal=SIGINT
    SyslogIdentifier=domain_com // [!code focus]
    User={{ data.linux_user }} // [!code focus]
    Environment=ASPNETCORE_ENVIRONMENT=Production
    Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
    
    [Install]
    WantedBy=multi-user.target

    WARNING

    • Change 3000 to the proxy port you declared when creating the website before
    • Please change domain.com to the domain name corresponding to your website
    • flashpanel is the user that the website is running on, please replace flashpanel with the user that the website is running on (be careful not to set it as root)
    • bin/Debug/netcoreapp8.0/publish/domain_com.dll is the path to the dll file that dotnet publish creates
    • Linux has a case-sensitive file system. Setting ASPNETCORE_ENVIRONMENT to Production will result in searching for the configuration file appsettings.Production.json, not appssettings.production.json.
    • The colon separator (😃 is not supported in environment variable names. Use double underscores (__) instead of colons. The system will convert double underscores to colons when environment variables are read into the configuration. In the following example, the connection string key ConnectionStrings:DefaultConnection is placed in the service definition file as ConnectionStrings__DefaultConnection
      ini
      Environment=ConnectionStrings__DefaultConnection={Connection String}

Visit the website to see the successful results!