I have a site that I've converted from VB.NET to C#.NET and every time I run this site in C#.NET, I get the following error:
Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
Source Error:
<membership>
<providers>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
The weird thing is that I don't get this error if I run the original VB.NET site. I get this error only when I run the C#.NET site.
Both site has identical web.config files and machine.config file can't be wrong since it works with VB.NET site. Is there anything I am missing?
Do you have an entry called LocalSqlServer in your connectionStrings section of the web config? Is the case the same for the key? Is there a backslash in it?
There is a trick....
Seems Web Forms app with membership "hides" this from you. You need to do the following:
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=YourServer;Initial Catalog=YourDB;Integrated Security=true"
providerName="System.Data.SqlClient" />
Or at the very least run the first line to remove the "current" one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.