Roles are not working online, locally is OK. Please help!

Discussion in 'ASP.NET 2.0' started by jung1974, Mar 26, 2006.

  1. I am trying to set up the Membership using the ASP.NET 2.0 membership system,but I am keep getting below error.
    I've already set up all the tables ( user, role, membership) in SQL server 2005...
    DO you have any idea why I am getting this error?

    There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

    The following message may help in diagnosing the problem: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)



    Here is the code in web.conf file






    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">


    <connectionStrings>


    <add name="ASPNETDB" connectionString="Data Source=(Dataservername);Integrated Security=false;Initial Catalog=(mydatabasename);User ID=(myuserid);Password=(password)" providerName="System.Data.SqlClient"/>





    </connectionStrings>


    <system.web>


    <authentication mode="Forms">


    <forms name=".ASPXAUTH"


    loginUrl="default.aspx"


    protection="All"


    timeout="30"


    path="/"


    requireSSL="false"


    slidingExpiration="true"


    defaultUrl="default.aspx"


    cookieless="UseCookies"


    enableCrossAppRedirects="false"/>


    </authentication>


    <membership defaultProvider="QuickStartMembershipSqlProvider" userIsOnlineTimeWindow="15">


    <providers>


    <add


    name="QuickStartMembershipSqlProvider"


    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"


    connectionStringName="ASPNETDB"


    enablePasswordRetrieval="false"


    enablePasswordReset="true"


    requiresQuestionAndAnswer="true"


    applicationName="SecurityQuickStart"


    requiresUniqueEmail="true"


    passwordFormat="Hashed"/>


    </providers>


    </membership>


    <roleManager


    enabled="true"


    cacheRolesInCookie="true"


    defaultProvider="QuickStartRoleManagerSqlProvider"


    cookieName=".ASPXROLES"


    cookiePath="/"


    cookieTimeout="30"


    cookieRequireSSL="false"


    cookieSlidingExpiration="true"


    createPersistentCookie="false"


    cookieProtection="All">


    <providers>


    <add name="QuickStartRoleManagerSqlProvider"


    type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"


    connectionStringName="ASPNETDB"


    applicationName="SecurityQuickStart"/>


    </providers>


    </roleManager>





    <pages theme="Default"/>


    <authorization>


    <allow users="*"/>


    </authorization>


    </system.web>


    <location path="secured">


    <system.web>


    <authorization>


    <deny users="?"/>


    <allow users="*"/>


    </authorization>


    </system.web>


    </location>


    <location path="administrators_role">


    <system.web>


    <authorization>


    <allow roles="Administrators" />


    <deny users="*"/>


    </authorization>


    </system.web>


    </location>


    </configuration>
     
  2. Ifound the answer. I needed to include the property applicationName in my tag provider.


    <add applicationName="/appname" name="CustomizedRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyDB" />
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    this error means you are trying to connecting using Named Pipes protocol which only work over LAN.


    Try change


    <add name="ASPNETDB" connectionString="Data Source=(Dataservername);Integrated Security=false;Initial Catalog=(mydatabasename);User ID=(myuserid);Password=(password)" providerName="System.Data.SqlClient"/>


    to


    <add name="ASPNETDB" connectionString="Data Source=tcp:(Dataservername);Integrated Security=false;Initial Catalog=(mydatabasename);User ID=(myuserid);Password=(password)" providerName="System.Data.SqlClient"/>


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. Hello,
    I need some help. I have the following problem.
    I can create a new user using the ASP.NET 2.0 membership system and then as part of the registration process assign this new user into a role. Everthing works fine locally, but when I upload my .aspx files to the Host and try to create a new userI cannot assign a role to it. The database that I am using is in the sql2k5XX.discountasp.net server.
    This is myweb.config file. Looks like for some reason is not reading the roleManager tag.






    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">


    <connectionStrings>


    <add name="MyDB" connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=user;Password=" providerName="System.Data.SqlClient"/>


    </connectionStrings>


    <system.web>


    <authorization>


    <allow users="?" />


    </authorization>





    <authentication mode="Forms" />


    <membership defaultProvider="CustomizedMembershipProvider">


    <providers>


    <add connectionStringName="MyDB" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" name="CustomizedMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>


    </providers>


    </membership>


    <roleManager defaultProvider="CustomizedRoleProvider"


    enabled="true">


    <providers>


    <add name="CustomizedRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyDB" />


    </providers>


    </roleManager>





    <compilation debug="true"/></system.web>


    <system.net>


    <mailSettings>


    <smtp from="<a target="_blank" href='mailto:[email protected]"><network'>[email protected]">


    <network</A> host="mail.mydomian.com" password=""userName="" />


    </smtp>


    </mailSettings>


    </system.net>


    </configuration>
    This is the error that I received.... Any idea is welcome!!!!
    Thank you, have a nice day,
    Papo.[​IMG]
    The role 'RoleA' was not found. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Configuration.Provider.ProviderException: The role 'RoleA' was not found.

    Source Error:





    Code:
    Line 18:     Public Sub AssignUserToRoles_Deactivate(ByVal sender As Object, ByVal e As EventArgs)
    Line 19:         '// Deactivate event fires when user hits "next" in the CreateUserWizard 
    Line 20:         Roles.AddUserToRole(CreateUserWizard1.UserName, "RoleA")
    Line 21:         'Dim i As Integer
    
     

Share This Page