membership/roles with Visual Studio 2008

Discussion in 'ASP.NET 2.0' started by jfasenmyer, Jan 8, 2008.

  1. Were you able to run aspnet_regsql successfully? If so, where in the process are you having a problem? I recently setup the default membership provider in '08 using the same process. Hoping maybe I can be of some help.
     
  2. I am using Visual studio 2008 with asp.net framework 3.5. I cant seem to get the membership/roles working.
    The article below doesnt seem to apply
    http://kb.discountasp.net/article.aspx?id=10413

    Can someone provide some pointers for membership/roles with 2008?

    ---Jek
     
  3. This is the sequence when i ran the regsql.exe from the cmd prompt.

    ///////////////////////////////
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S DBServerName
    -U DBLogin -P Password -A all -d DBName
    Start adding the following features:
    Membership
    Profile
    RoleManager
    Personalization
    SqlWebEventProvider
    ...............
    An error has occurred. Details of the exception:
    An error has occurred while establishing a connection to the server. When conne
    cting 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)
    Unable to connect to SQL Server database.

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>
    ////////////////////////////////////////////////////

    ---Jim
     
  4. Are you replacing the namespaces(in red) while executing 'aspnet_regsql.exe -S DBServerName</font> -U DBLogin</font> -P Password</font> -A all -d DBName</font>' by values related to your MS SQL database ?

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. I had working a data-driven web site using a SQL database that I added successfully perDASP instructions.

    I used the following definition in my Connection String:

    "Data Source=tcp:sql2k511.discountasp.net;
    Initial Catalog=SQL2005_441416_gvops;
    User ID=SQL2005_441416_gvops_user;
    Password=******;"

    all worked great til I added the capability for membership/roles to my local site.
    Now I have the users/members/roles locally stored in ASPNETDB.MDF with all the user-specific info.

    This works fine on my local computer.

    Do I need toaddanother database (300MB @ $10/mo), and then upload and register this databaseto get this working?

    I'm not sure where the regsql.exe fits into all this cause I didnt use it with my original data-driven web site.

    ---Jim
     
  6. You can have the membership database as well as your application database co-exist on a single DASP database account.Remember,using the attach tool for any of the mentioned databases will overwrite the already existing database.You can avoid this by using the 'aspnet_regsql.exe' tool to create the membership schema after you attach your web application database using SQL Tools(in the DASP Control Panel). [See http://kb.discountasp.net/article.aspx?id=10413 for instructions] You will have to re-create the roles/users in the above case.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. You would want to run the following...

    aspnet_regsql.exe -S sql2k511.discountasp.net -U SQL2005_441416_gvops_user -P****** -A all -d SQL2005_441416_gvops

    (Replace the password '******' with your db password)

    Thisshouldcreatethe necessary aspnet_<name> tables &amp; views for the Membership Provider on your DASP SQL database. At this point you no longer should need the ASPNETDB.mdf file and should be able to complete the remainder of the steps listed in the link you posted earlier. It will not move your existing data over though from the ASPNETDB.mdf. If you have a considerable number of users &amp; roles already created in the local mdf, you might be able to use the DASP utility but I'm not sure as I've never used it.
     
  8. let me see if I can understand.

    I have a single app-specific SQL database called "database.mdf".
    I also have the generic ASPNETDB.MDF automatically installed to my local web site when I ran the
    Web Site Administration Tool that comes with MS Visual Studio2008.

    I uploaded database.mdf to the DASP FTP site using the Copy Web Site utility from Visual Studio 2008.

    I used the DASP utility to attach database.mdf and then renamed the connection strings
    according to


    "Data Source=tcp:sql2k511.discountasp.net;
    Initial Catalog=SQL2005_441416_gvops;
    User ID=SQL2005_441416_gvops_user;
    Password=******;"

    This all worked fine til I added in the members/roles.

    Next you suggest I execute:
    aspnet_regsql.exe -S DBServerName -U DBLogin -P Password -A all -d DBName
    with the red values related tomy MS SQL database.

    where do I get the values in red?
    Do they correspond to the info provided by DASP for my attached file database.mdf?

    When do I do anything with the file ASPNETDB.MDF that seemed to cause the problem in the first place?

    Guess I'm a bit dense but I'm doing my best to follow these rules!!

    ---Jim
     
  9. You're getting very close! I think I see the problem...

    In step 3 of the link you originally posted it states to add the following to your web.config...

     
  10. thanks fo all the help. I believe i am close. I ran all the various steps and seem to get the right response. However, when I go live in DASP and attemp to login, I get the response below. I entered the users and roles in the web config but seems i didnt get the users to be recognized ...
    Server Error in '/' Application.


    Login failed for user 'DBLogin'.


    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.Data.SqlClient.SqlException: Login failed for user 'DBLogin'.

    Source Error:





    Code:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:





    Code:
    [SqlException (0x80131904): Login failed for user 'DBLogin'.]
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800131
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
       System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
       System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +172
       System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +381
       System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
       System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +357
       System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
       System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
       System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
       System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
    
     
  11. I found this comment (below in red)from Vikram. This suggests that I add the users/roles


    to the local website using the local tool and then upload this to the DASP site. I didnt see this discussed in


    http://kb.discountasp.net/article.aspx?id=10413


    ---Jim





    Once you create the roles/users on the local version of your membership database,you can attach that database to your DASP SQL server account using the SQL tools in the control panel (https://my.discountasp.net/mssql2005-tools.aspx).Optionally,you can attach the database first,update your connection string in your appln web.config and your asp.net confirguration tool will then interact the remote version of the database directly.




    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  12. jtf -- thanks for the response -- i, in fact, had the correct dbname/pw, etc. see commented connection strings below.

    Now seems I have clobbered my ability to return to the operational form of my web site running on my local server.
    Now when I replace the connection strings to SQLEXPRESSas below, my website behaves strangely on my local server.
    Does aspnet_regsql.exe do something that must be undone to run locally?
    ---Jim


    <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"


    providerName="System.Data.SqlClient" />


    <add name="NamesConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"


    providerName="System.Data.SqlClient" />





    <!--


    <add name="ConnectionString" connectionString="Data Source=tcp:sql2k511.discountasp.net;


    Initial Catalog=SQL2005_441416_gvops;


    User ID=SQL2005_441416_gvops_user;


    Password=XXXXXXX;"


    providerName="System.Data.SqlClient" />





    <remove name="LocalSqlServer" />


    <add name="LocalSqlServer" connectionString="Data Source=tcp:sql2k511.discountasp.net;


    Integrated Security=false;


    Initial Catalog=SQL2005_441416_gvops;


    User ID=SQL2005_441416_gvops_user;


    Password=XXXXXXX"


    providerName="System.Data.SqlClient" />


    -->
     

Share This Page