locked
Creating/locating the ASPNETDB.MDF file RRS feed

  • Question

  • User1318367839 posted

    I am going through O'REILLY's Learning ASP.NET 3.5 and despite some of the bugs I successfully made my way to Chapter 9: Security.  This is where the floor has fallen out from underneath me.  It appears the author(s) got tired or something and skipped some of the steps required to actually create Users and the ASPNETDB.MDF file.  I had previously put up a post on this site and thankfully someone was able to provide the correct steps needed to create Users.

     Unfortunately, the book mentions that the ASPNETDB.MDF is magically created but that is not the case.  From what I researched it should have been created when I simply opened the ASP.NET Configuration.  I did a search for it and found a copy which was created almost two years ago, probably with a previous version of .NET.  I tried this file and as expected the Test Connection button displayed a failed message.

    Any help will be greatly appreciated and I can't wait to actually start catching on to this stuff.

     

     

    Saturday, February 7, 2009 10:52 AM

Answers

  • User-2008565010 posted

    check it on your local sql Server..

    Or how about starting from scratch..

    Create a new empty Database and name it MyAspNetDB...

    Then in your web.config modify your LocalSqlServer connectionString to that Database .... Then run the aspnet configuration Tool and see if aspnet tables get dumped into that Database...

    Also check this: http://www.asp.net/learn/security/tutorial-04-vb.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 9, 2009 6:47 PM

All replies

  • User-1593004730 posted

     

    From what I researched it should have been created when I simply opened the ASP.NET Configuration.

    Did you create Roles and Users when You used the Asp.Net Configuration feature on your local box?

    I believe you need to set up a role and a user or two in Configuration and the membership aspnetdb.mdf database will be created in the App_Data folder.

    Saturday, February 7, 2009 11:25 AM
  • User-2008565010 posted

    Addition to above post...

    You can run aspnet_regsql utility to create it explicitly and modify the connection string in your web.config.

    check this: http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

    Saturday, February 7, 2009 1:23 PM
  • User1318367839 posted

     

    From what I researched it should have been created when I simply opened the ASP.NET Configuration.

    Did you create Roles and Users when You used the Asp.Net Configuration feature on your local box?

    I believe you need to set up a role and a user or two in Configuration and the membership aspnetdb.mdf database will be created in the App_Data folder.

     Yes I created Users and Roles.  I created the users first and then the book mentioned the file so I figured I'd take a look and it wasn't there so I created some Roles but that did not help.

    Saturday, February 7, 2009 8:47 PM
  • User-1593004730 posted

    I had previously put up a post on this site and thankfully someone was able to provide the correct steps needed to create Users.

    To save time, you should explain thoroughly the steps you have taken and whatever other relevant info.

    Do you have a folder "App_Data" in solution explorer? 

    Specifically with the steps you took, how did you create the users and roles?

    Using the Website Administration Tool (ASP.Net Configuration), did you Select authentication type "From the Internet" under the "Security" tab

    Using the Website Administration Tool (ASP.Net Configuration), did you select "AspNetSqlProvider
    under the "Provider" tab?

    Using the Website Administration Tool (ASP.Net Configuration), did you create the roles and users under the "Security" tab?

    Saturday, February 7, 2009 10:56 PM
  • User1318367839 posted

    The original problem is at http://forums.asp.net/p/1376602/2923980.aspx#2923980.  What I had to do get by this problem was make the following change to my web.config:

    <connectionStrings>
         <remove name="LocalSqlServer"/>
         <add name="LocalSqlServer"
            connectionString="Data Source=localhost;&#xD;&#xA;       
     Initial Catalog=AdventureWorks;&#xD;&#xA;       
     Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

    There was something along the way in the "Web Site Administration Tool" (ASP.Net Configuration) that changed (I think it was my servername/local machine) to &#xD;&#xA.  This may have been for security reasons?

    It may have been when I chose from the Security tab:
    1.) Select authentication type
    2.) From the internet
    option

    From here I proceeded to add three Users and two Roles using the links through the Security tab.  I went to "Manage Users" and verified they're there.  I also went to "Create or Manage roles" and verified those exist.  I also assigned Roles to my Users and all the Users are "Active".

    I chose and still have AspNetSqlProvider under the "Provider" tab.

    After all this I do not have a folder "App_Data" in solution explorer.

    I highlighted Data Connections and tried to Refresh but it still didn't show.

    I clicked on the "Use the security Setup Wizard to configure security step by step." link but did not proceed any further.  I also did not choose "Access Rules" because I did not get that in the book (If they exist).

    I believe that is everything.  I hope this helps you help me and I appreciate your time.

    Sunday, February 8, 2009 8:33 AM
  • User-1593004730 posted
    Navigating this path in Windows Explorer, do you see the aspnetdb.mdf file:

    c:\program files\microsoft sql server\mssql.1\mssql\data\aspnetdb.mdf

    If the ASPNETDB.MDF file is there, it was created when you ran the aspnet_regsql tool. The Website Administration Tool will use the connectionString for LocalSqlServer that is in your web.config file. So, if you have a connectionString and are able to connect, then it must be working.

    I just made a new test site with Visual Web Developer 2008 Express and ASP.Net 2.0. App_Data was created by VWD at inception. When I added a role and a user with the WAT and closed  the WAT, I refreshed the site and ASPNETDB.MDF is in the APP_DATA folder.

    This local website file, ASPNETDB.MDF that the WAT created is attached to SQLEXPRESS by the default connectionString found in  c:\windows\microsoft.net\framework\v2.0.50727\config\machine.config.

    Did you make a login page? Can you log in?

    If you are able to log in, then the connection to the database must be working. You should be connecting to the ASPNETDB.MDF database created with the aspnet_regsql tool via the connectionString.

    Here is a great tutorial about membership:

    http://www.asp.net/LEARN/videos/video-06.aspx
    Sunday, February 8, 2009 2:14 PM
  • User-2008565010 posted

     <add name="LocalSqlServer"
            connectionString="Data Source=localhost;&#xD;&#xA;       
     Initial Catalog=AdventureWorks;&#xD;&#xA;       
     Integrated Security=True"
            providerName="System.Data.SqlClient" />

    Is that the connectionString you have in your web.config???

    If yes ... The aspnetDB will not be in the App_data folder....

    For all Membership and Roles tables you should check on Your DBServer Name in Data Source=localhost;&#xD;&#xA; 

    and

    under Database name mentioned in  Initial Catalog=AdventureWorks;&#xD;&#xA;

    You should look for tables e.g aspnet_Membership, aspnet_Users and so on. You will find your users and Roles created there.

    i.e whatever database name you give in Initial Catalog ...the aspnet_regsql script that run implicitly by Website Admin tool will dump all Membership and Roles tables in that DB.

    Sunday, February 8, 2009 4:03 PM
  • User1318367839 posted

    add name="LocalSqlServer"
            connectionString="Data Source=localhost;&#xD;&#xA;       
     Initial Catalog=AdventureWorks;&#xD;&#xA;       
     Integrated Security=True"
            providerName="System.Data.SqlClient" />

    Is that the connectionString you have in your web.config???

    Yes, the interface changed the name from what I had to ;&#xD;&#xA.  I figured it was for security reasons.

     

    I had other versions of SQL on my machine but unistalled them so I could work with 2005 Express with .NET 2008.  I did a search for ASPNETDB.MDF and found it in another directory but when I clicked the Test Connection button for the Add Connection tool for .NET 2008 it failed.  The date of the file was almost two years old so it cannot be the one I recently created.

    Monday, February 9, 2009 6:21 AM
  • User-2008565010 posted

    so is ;&#xD;&#xA and encrypted name for AdventureWorks???

    if yes did you check your AdventureWorks database for aspnet Tables?

    Monday, February 9, 2009 11:41 AM
  • User1318367839 posted

    so is ;&#xD;&#xA and encrypted name for AdventureWorks???

    Sorry, I don't know.  I was surprised to see ;&#xD;&#xA appear.  The book didn't say anything about something like happening.

    if yes did you check your AdventureWorks database for aspnet Tables?

    Where would I check to see if AdventureWorks is my database for aspnet tables?

    Monday, February 9, 2009 6:07 PM
  • User-2008565010 posted

    check it on your local sql Server..

    Or how about starting from scratch..

    Create a new empty Database and name it MyAspNetDB...

    Then in your web.config modify your LocalSqlServer connectionString to that Database .... Then run the aspnet configuration Tool and see if aspnet tables get dumped into that Database...

    Also check this: http://www.asp.net/learn/security/tutorial-04-vb.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 9, 2009 6:47 PM