Users validation database RRS feed

  • Question

  • Hello,


    I have a Win32 application and a i am validating a user in the "aspnetdb" database.


    I'm using Visual Studio 2005, and the database that the .NET framework uses is not the database i created: the framework is using a database under the 'bin\Release\App_Data' folder, and my users database is not there.


    How do i tell .NET where is the DataBase i created? Maybe some directive in App.config, but how?


    Thank you,



    Thursday, October 18, 2007 8:23 AM

All replies

  • If you doing ASP.NET application - check web.config file.

    Path to database file can be specified in connection string, check MSDN for connection string format.
    Thursday, October 18, 2007 10:00 AM
  • aspnetdb and App_Data folder are used for Membership in Asp.net pages.

    Are you writing a web application (web site) or really a win32 application?


    For modifing connection string check this site:





    Thursday, October 18, 2007 10:38 AM
  • Thank you Stefano.


    I'm writing a win32 application.


    I also did think that "App_Data" folder was used for Membership in Asp.net pages, but if you do something like this in a WinForm:


    System.Web.Security.MembershipCreateStatus MCS = new System.Web.Security.MembershipCreateStatus();


    System.Web.Security.Membership.CreateUser("Newuser", "password", email@somedomain.com, "Question?", "answer", true, out MCS);


    bool Valid = System.Web.Security.Membership.ValidateUser(@"Newuser", "password");


    The "Valid" bool variable will be true, as if there realy was a user called "Newuser". And this is right, because if i look for other user that i didn't create previously, it will return false.


    So, my problem is this:

    If i check at  the Aspnetdb database in my web application, there is no user called "Newuser". So the user wasn't created there. Were is he? Then if i look in my filesystem for another aspnetdb.mdf file, i will find it under "bin\Release\App_Data".


    What happened? I think that after using Membership in a windows form, the .net framework creates a new database under the application path.


    Now: how to tell the framework that the database to use is not that, but the database under the web application?


    And please no answer from someone at MSFT saying that this post belongs to Asp.Net



    Thursday, October 18, 2007 7:32 PM
  • Membership use default connection string "LocalSqlServer" in app.config and point to current App_Data folder inside application


    If u want to use a different database you have to remove "LocalSqlServer" connection string and add a new one inside configuration section in app.config:


    Code Block


    <remove name="LocalSqlServer"/>

    <add name="LocalSqlServer" connectionString="user id=[useridname];data source=[db server];persist security info=True;initial catalog=[dbname];password=[pwd]"

    providerName="System.Data.SqlClient" />




    Hope this helps, let me know!


    Saturday, October 20, 2007 1:54 PM
  • Thank you for your help Stefano, but now i have it all set and working.


    You are right: it was related to membership, but i'm basic in c# and the answer i needed was:


    In App.config create a <system.web> section and there something like:




    <add name="AspNetSqlMembershipProvider"

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




    applicationName="/" />




    And now it works.


    But i think that the .net platform has a subtle bug in this part, because nevertheless i can create users, see users, change users, and all this in the DataBase i pointed to, if i want to create a Role or add a user to a Role, the system keeps creating a new database called aspnetdb, under the application app_data folder and not in the database i needed.


    That behaviour proihibits me from maintaining my users under my application. That was not my intent after all, but in another application who knows?

    If you know what i'm doing wrong, or what i am missing i thank you in advance for your help.


    For last, sorry for my late answer, but i almost decided to discard this forum, not because of the members, but because MS people: they keeping transferring my posts to Asp.net section. And my posts don't have much to do with Asp.net, and obviously i keep getting always 0 replies.

    MS people do not read the entire posts, and it's enought for them to transfer the post to asp.net if they see expressions like 'aspnetdb'. But worse: i can not reply to them saying: 'Please move back my post to c# section, because it's there it should be" just because there is no "Reply" button.


    Thank you again Stefano.



    Sunday, October 21, 2007 10:46 AM