Preparations:
1.NET SDK >= 8.0 Download link:https://dotnet.microsoft.com/zh-cn/download
2.Visual Studio2022 Download link:https://visualstudio.microsoft.com/
3.SQL Server >= 2019 Download link:https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads
4.SQL Server Management Studio Download link:https://learn.microsoft.com/zh-cn/sql/ssms/
Necessary configuration:
In the appsettings.json file under the root directory
"ConnectionStrings": {
"DefaultConnection": "Server=nhdSQLEXPRESS;Database=SunuerManage;User Id=sa;Password=123456;MultipleActiveResultSets=true;TrustServerCertificate=True;Max Pool Size=100;Min Pool Size=5;Pooling=true;"
},
Server=nhd/SQLEXPRESS: Specifies the database server and instance name to connect to.
Database=SunuerManage: Specifies the default database name to connect to.
User Id=sa; Password=123456: Provides the credentials (username and password) needed to log in to SQL Server.
MultipleActiveResultSets=true: Allows multiple data-reading operations to occur simultaneously within the same database connection (session). For instance, one query can read data while another query is also running in parallel. This setting is especially important when using Entity Framework; if you need to iterate over data and perform other operations in a single connection, you must set this to true.
TrustServerCertificate=True: Determines whether to trust the server certificate when using TLS/SSL encryption to connect to SQL Server. With True, even if the certificate is not signed by a trusted CA or has other validation issues, it will still be trusted and establish the encrypted connection. Security note: In a production environment using self-signed or otherwise untrusted certificates, this option allows continued connections but can pose a security risk. Configure it carefully based on your needs.
Max Pool Size=100; Min Pool Size=5; Pooling=true: Controls the database connection pool behavior.
Pooling=true: Enables connection pooling, improving performance when the application frequently accesses the database and reducing the overhead of repeatedly opening/closing connections.
Max Pool Size=100: The maximum number of idle connections to keep in the pool. If this limit is exceeded, new connection requests must wait until a connection is freed or, depending on your configuration, an exception is thrown.
Min Pool Size=5: The minimum number of idle connections to retain in the pool. When the application first connects to the database, it initializes and keeps 5 connections on standby for quicker handling of subsequent requests.
Run the System:
After downloading and unzipping:
Locate the SunuerManage.sql file in the Data folder and restore it in your SQL Server database.
Open the SunuerManage.sln file with Visual Studio, edit the appsettings.json configuration file, and then click Run.
The following page will be displayed:
If you enter http://localhost:5021 in your browser and the page loads correctly, the configuration was successful.
Backend login address: http://localhost:5021/Manage/Login
Account: niqiu
Password: 123456
Deploying the System
Publish
In Visual Studio, right-click on the project name and select “Publish” to build and generate the deployment files.
Deploy to Server
Option A: Deploy to Windows IIS
Install IIS and .NET Extension
In “Server Manager,” add the “Web Server (IIS)” role.
Install “.NET Core Hosting Bundle / Extension” so that IIS can host .NET applications.
Create a Website
In IIS Manager, right-click on “Sites” and select “Add Website.” Point the physical path to the previously published folder (publish).
The port (default 80) or domain can be customized as needed.
App Pool Configuration
Create or select an application pool. For the .NET CLR version, you can choose either “No Managed Code” or the actual .NET CLR version (depending on what you installed). Set the pipeline mode to “Integrated.”
Ensure the “Identity” has the necessary access permissions for the published folder and the database (especially if Windows authentication is involved).
Test Access
Start IIS and access the configured domain or IP to check if Sunuer Manage runs correctly.
If you encounter a “500 error,” look in the IIS logs or the application event logs for details on the error.
Option B: Deploy to Linux (using Nginx reverse proxy)
Install .NET Runtime
Install the corresponding version of the .NET SDK/Runtime in your Linux environment (Ubuntu / CentOS / Debian, etc.).
Copy Published Files
Upload the publish folder to the server (e.g., /var/www/sunuer).
Navigate to that directory and run dotnet SunuerManage.dll (example) to test if it starts properly.
Configure Nginx
In the /etc/nginx/sites-available/ directory, create a configuration file (e.g., sunuer.conf). Example:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Forward requests to the port where the application is listening (default is 5000). You can specify this port in appsettings.json or via command-line arguments.