locked
problem of configuring authorization RRS feed

  • Question

  • User76000080 posted

    hello  community,

    I have a problem concerning the management of authorization to the pages of a web application that I develop in asp.net with sql server 2008 r2 external database. I have configured my database by executing the framework aspnet_reqsql 4 since I use Visual Studio 2010 to develop my application. when I run the asp.net website administration tool, and I click the Security tab I get the following error: "An error occurred during initialization of an object attempts . System.Data.SqlClient.SqlConnection the value provided for the connection string is incorrect or the syntax is valid may not parameter name. connectionString "
    so I use forms authentication via a table "employee" contained in my database to connect to my application
    is what this error is because I am using sql server 2008 r2 for my database?
    If yes / no, how to solve the problem.

      here is the creation of code for my membership and rolemanager to the web.config:

    <membership defaultProvider="HEALTHBOARD_Membership">
       <providers>
        <clear />
        <add connectionStringName="ApplicationServices" enablePasswordRetrieval="false"
         enablePasswordReset="true" requiresQuestionAndAnswer="false"
         requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
         applicationName="/" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" />
         
        <add connectionStringName="csthealthboard" name="HEALTHBOARD_Membership"
         type="System.Web.Security.SqlMembershipProvider" />
       </providers>
      </membership>
    
       
    		<profile>
    			<providers>
    				<clear/>
    				<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
    			</providers>
    		</profile>
    
    	<roleManager enabled="true" defaultProvider="HEALTHBOARD_RoleManager">
       <providers>
        <clear />
        <add connectionStringName="ApplicationServices" applicationName="/"
         name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
        <add applicationName="/" name="AspNetWindowsTokenRoleProvider"
         type="System.Web.Security.WindowsTokenRoleProvider" />
         
        <add connectionStringName="csthealthboard" name="HEALTHBOARD_RoleManager"
         type="System.Web.Security.SqlRoleProvider" />
       </providers>
      </roleManager>

    please help me

    Tuesday, December 30, 2014 11:46 AM

All replies

  • User76000080 posted

    up please somebody help me

    Tuesday, December 30, 2014 12:23 PM
  • User1564875471 posted

    Can you please show your connectionstrings section from your web.config  (without your real user/pass please) ? Also, I remember that the Web configuration tool require a connection string with name "LocalSqlServer", so try to add a connection string with that name and give it the same connection string of your app.

    Tuesday, December 30, 2014 4:10 PM
  • User76000080 posted

    hello anas 

    here is my connectionstrings section from my web.config

    <configuration>
    	<connectionStrings>
        <add name="ApplicationServices"
             connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
             providerName="System.Data.SqlClient" />
        
    		<add name="csthealthboard" connectionString="Dsn=dshealthboard;uid=sa;pwd=aspnetnarom" providerName="System.Data.Odbc"/>
    	</connectionStrings>

    Tuesday, December 30, 2014 6:10 PM
  • User76000080 posted

    the first is the applicationservices connectionstring and the second is the connectionstring I created

    Tuesday, December 30, 2014 6:13 PM
  • User76000080 posted

    I changed the name of my connectionstring "ApplicationServices" with "LocalSqlServer" but it still does not work.
    can you give me more information on the use of "LocalSqlServer"

    Tuesday, December 30, 2014 6:34 PM
  • User76000080 posted

    up help me please

    Tuesday, December 30, 2014 8:07 PM
  • User-1151753377 posted

    Hi narom,

    Welcome to the ASP.NET forum.

    According to your description, I noticed that you make some Membership configuration in web.config file

    Please refer to the code below that Membership configuration.

    1. Configure the Connection String

    <connectionStrings>
        <add name="ConnStr" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MemberShip_RoleManager-20141118052934.mdf;Initial Catalog=aspnet-MemberShip_RoleManager-20141118052934;Integrated Security=True"
          providerName="System.Data.SqlClient" />
      </connectionStrings>

    2. Configure Memberhsip

    <membership defaultProvider="mySqlMembershipProvider">     //the defaultProvider and name is consistent
          <providers>
            <add name="mySqlMembershipProvider"
                type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                connectionStringName="ConnStr"        //ConnectionString Name
                 
                enablePasswordRetrieval="false"
                enablePasswordReset="true"
                requiresQuestionAndAnswer="false"
                applicationName="TestMembership"
                requiresUniqueEmail="true"
                passwordFormat="Hashed"
                maxInvalidPasswordAttempts="5"
                minRequiredPasswordLength="6"
                minRequiredNonalphanumericCharacters="0"
                passwordAttemptWindow="10"
                passwordStrengthRegularExpression=""/>
          </providers>
        </membership>

    3. Configure RoleManager

    <roleManager enabled="true" defaultProvider="myAspNetSqlRoleProvider">     //the defaultProvider and name is consistent
          <providers>
            <add name="myAspNetSqlRoleProvider"
                 connectionStringName="ConnStr"    //The Connection String Name 
                 applicationName="TestMembership"
                 type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          </providers>
        </roleManager>

    4. Configure Forms authentication

    <authentication mode="Forms">
          <forms loginUrl="MemberShipWebsite\Login.aspx"
                 protection="All"
                 timeout="30"    
                 name=".ASPXAUTH"
                 path="/"
                 slidingExpiration="true"
                 defaultUrl="MemberShipWebsite\AllUser\Default.aspx"  
                 cookieless="UseDeviceProfile"/>
        </authentication>

    Best Regards,

    Summer

    Tuesday, December 30, 2014 10:22 PM
  • User76000080 posted

    Summer

    thank you for your reply I try it and I'll make you return

    Wednesday, December 31, 2014 8:17 AM
  • User76000080 posted

    hello summer

    when I apply your changes here is the error I:

    "Unable to establish a connection to a SQL Server database"

    Can you give me more details on the changes you proposed to me.

    I remember that I use sql server 2008 r2 to my database.

    up please

    Wednesday, December 31, 2014 9:00 AM
  • User-1151753377 posted

    Hi

    "Unable to establish a connection to a SQL Server database"

    About this issue, I think it is caised by your database connection. so check whether you connectionString is correct, and confirm the database is exist and the path is right.

    connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MemberShip_RoleManager-20141118052934.mdf;
    

    Best Regards,

    Summer

    Thursday, January 1, 2015 9:31 PM
  • User76000080 posted

    Hello Summer

    I am sincerely sorry for not having replied earlier because of malaria that had struck me.

    I have applied the different solutions that you proposed to me but it still does not work. the error persists

    Monday, January 12, 2015 8:13 PM
  • User76000080 posted

    up

    Wednesday, January 14, 2015 12:50 AM