.NET 4.0 C # Initialization String Does Not Match Login Error

I am writing a small web application in C # .NET4.0 to try to find out about this and get used to writing applications with it.

My application is very simple; it has a home page, a login button that will lead you to the login form, and when you log in, you can go to the admin page.

The entire login process is done using .NET controls, and my database was created using the command Aspnet_regsql.exethrough the visual studio (2010) command line.

I have only built and tested on my local machine so far, and now I want to try and test on a server with IIS7.

I installed the site correctly in IIS7, and I can create and download the site without any problems, that is, until I try to log in. The SQL version that I used on my local machine is 2008 R2, while the SQL version on the server is simple in 2008. Because of this, I couldn’t just back up my local database and restore it to SQL on the server, so instead I generated scripts and used these scripts to create a database on the server.

Now, when I try to log in to a site that is on the server, I get the following error:

Format of the initialization string does not conform to specification starting at index 0.

After trying to look at the Internet for a solution, I found that this could be a problem for my connection strings, so I tried changing them to all kinds of things without success.

visual studio - ; DAL, BLL .

, , , :

DAL (app.config) ( - . " 2" )

<add name="DAL.Properties.Settings.APPNAMEConnectionString"
   connectionString="Data Source=localhost;Initial Catalog=(DATABASE NAME);uid=(USER ID);pwd=(PASSWORD)"
   providerName="System.Data.SqlClient" />

(web.config) ( - . " 2" )

<add name="LocalSqlServer" connectionString="server=localhost;database=(DATABASE NAME);uid=(USER ID);pwd=(PASSWORD)"/>

, - #.NET 4.0 , , .

!

1:

Dan F , web.config:

    <membership>
        <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
            connectionStringName="LocalSqlServer"
            applicationName="/APPNAME"
            enablePasswordRetrieval="false"
            enablePasswordReset="true"
            requiresQuestionAndAnswer="false"
            requiresUniqueEmail="true"
            passwordFormat="Hashed"
            maxInvalidPasswordAttempts="5"
            minRequiredPasswordLength="5"
            minRequiredNonalphanumericCharacters="0"
            passwordAttemptWindow="10"
            passwordStrengthRegularExpression=""/>
        </providers>
    </membership>
    <profile>
        <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/APPNAME" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </profile>
    <roleManager enabled="true">
        <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/APPNAME" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="AspNetWindowsTokenRoleProvider" applicationName="/APPNAME" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </roleManager>

2: DAL, , aspnet_regsql.exe, . DAL app.config web.config, , .

Membership.GetUser() , , , , .

app.config web.config :

Data Source=.;Initial Catalog=(DATABASE);User Id=(USERID);Password=(PASSWORD);
+5
3

, , . cs aspx , .NET, " ", , .

.NET Visual Studio, , web.config.

, , web.config, (, ), :

Data Source=.;Initial Catalog=(DATABASE);User Id=(USERID);Password=(PASSWORD);

web.config, (, ), :

$(ReplacableToken_test-Web.config Connection String_0)

, .

+5

, . ?

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
0

This is what resolved this for me when my aspx file executed the sql command in VS, but not from my IIS 7 server.

I went into the IIS`sites \site` and clicked the connection string icon. Then I notified the working (in VS) connection string for LocalSqlServer, restarted IIS, and everything was fine.

0
source

All Articles