This guide shows you how to add a database connection string to your web.config file in Plesk. Connection strings allow your ASP.NET application to connect to SQL Server or other databases by storing credentials and server information in a central configuration file.
How to Add a Connection String
-
Step 1: Log in to Plesk
Access your Plesk control panel with your credentials.
-
Step 2: Open File Manager
Choose the Files option to access the File Manager.
-
Step 3: Navigate to web.config
Navigate to the
httpdocsfolder and open theweb.configfile. -
Step 4: Insert the connection string code
In the Code Editor window, insert the following code into the
<configuration>section:<connectionStrings> <add name="ConnectionString" connectionString="Data Source=SERVER_IP;Initial Catalog=DBname;User Id=DBuser;Password=DBuser_password;" providerName="System.Data.SqlClient" /> </connectionStrings>Replace
SERVER_IP,DBname,DBuser, andDBuser_passwordwith your actual database server IP, database name, username, and password. -
Step 5: Save the file
After making the changes, click the Save button to apply the configuration.