Answered by:
The connection name 'ConnectionString' was not found in the applications configuration or the connection string is empty.

Question
-
User-2062901272 posted
Hi experts,
I have been receiving this error in my web config. can anyone help me with this all the suggestion that i have find does not help me.
The error gives me
Server Error in '/' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: The connection name 'DNSConnectionString' was not found in the applications configuration or the connection string is empty. Source Error: Line 66: <clear /> Line 67: <remove name="AspNetSqlRoleProvider" /> Line 68: <add connectionStringName="DNSConnectionString" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> Line 69: </providers> Line 70: </roleManager> Source File: D:\My Digital Dashboard and Mini Programs\_Source Codes\DNSold2\InvoiceWebSite\web.config Line: 68 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3062.0
Monday, July 16, 2018 1:29 AM
Answers
-
User-369506445 posted
you can put your connection String on your IIS with an Encrypt password, it's safe
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, July 16, 2018 5:10 AM
All replies
-
User-369506445 posted
hi
your connection name must be inside connectionStrings Tag
your config file must be below like :
<configuration> <connectionStrings> <add name="DNSConnectionString" connectionString="Data Source=SqlServerName;Initial Catalog=yourDatabase;User ID=sa;Password=PASS@123" providerName="SQLOLEDB.1"/> </connectionStrings> . . . .
Monday, July 16, 2018 4:45 AM -
User-2062901272 posted
Hi vahid,
Thanks for your reply,
I have added my connection string on the IIS as per system requirements, i must not put it on the web.config file.
is there a way how can i solved this error just using my IIS config for connection string.
Thanks and Best Regards.
Monday, July 16, 2018 5:06 AM -
User-369506445 posted
you can put your connection String on your IIS with an Encrypt password, it's safe
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, July 16, 2018 5:10 AM -
User-369506445 posted
also, you can don't put it in web config, you can set it in your code
web config
<connectionStrings> <remove name="MyLocalSQLServer" /> <add name="MyLocalSQLServer" connectionString="" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <membership defaultProvider="MySqlMembershipProvider" > <providers> <clear/> <add name="MySqlMembershipProvider" connectionStringName="MyLocalSQLServer" applicationName="MyAppName" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership> </system.web>
code
try { Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConnectionStringsSection conSection = (ConnectionStringsSection)config.GetSection("connectionStrings"); string str = "Data Source=.;Initial Catalog=SampleDatabase;User ID=ID;Password=Pwd"; conSection.ConnectionStrings["MyLocalSQLServer"].ConnectionString = str; config.Save(); } catch (Exception ex) { Response.Write(ex.Message); }
please follow below links:
https://forums.asp.net/t/1160276.aspx?reading+the+membership+section+in+web+config
https://stackoverflow.com/questions/16903988/membershipprovider-change-connection-string-in-code
Monday, July 16, 2018 5:20 AM -
User-1171043462 posted
The correct process is to encryot connection string and decrypt in code as shown in my article
Monday, July 16, 2018 8:31 AM -
User283571144 posted
Hi ryoka012,
I have added my connection string on the IIS as per system requirements, i must not put it on the web.config file.
is there a way how can i solved this error just using my IIS config for connection string.
As far as I know, multiple IIS management console setting will also modify the web application's web config.
For exmaple,. you could modify the url rewrite setting in the IIS manager console.
If you apply the setting, you could find the url rewirte rule has already added into the web application's web config.
So I suggest you could direclty open the web.config file in the web application and modify the connection string tag.
If you want to add the connection string in the IIS manager console, I suggest you could open the IIS manager console and find the connection string setting and add the DNSConnectionString with the database connection string.
Best Regards,
Brando
Wednesday, July 18, 2018 1:52 AM