ASP.NET: How can I explore the default user database - asp.net

So if I create a new MVC project with basic log in template, there should be somewhere a database which contains all the user login information. There's even the default connection string which points to it.
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MyProjectName-20140521042155.mdf;Initial Catalog=aspnet-MyProjectName-20140521042155;Integrated Security=True" providerName="System.Data.SqlClient" />
How ever, when exploring the project folder I cannot find it. I also tried to turn on "show all files" option in the solution explorer.

Sql Server Management Studio can be used to connect to the local db server. You can also use visual studio server explorer.

Related

ASP.NET VB change db connection on web forms framework

I have created an instance of ASP.NET Web Forms in my Microsoft Visual Studio. By default the program generates user login page and registration which are linked to the .mdb file.
I want to reconfigure the standard connection and link it to my instance of MSSQL 2012 SQLExpress server.
How can I do it?
Ok so I will give some direction and link you to a page.
First let me ask you this the connection you are using presently is it in a web.config file. If so this is where you will change the server/instance and database/catalog name.
Web.Config modification for SQL Server Instance
or this link
Web Config modification for SQL Express 2
So if you in the web.config file you should see something similar to this.
<ConnectionStrings>
<add name="" connectionString="Server=(localhost)\SqlExpress;Max Pool Size=300;Initial Catalog=database;User ID=username;Password=password;" providerName="System.Data.SqlClient"/>
</Connectionstrings>
or
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source= (LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\database.mdf;Initial Catalog=database;Integrated Security=True" providerName="System.Data.SqlClient" />
you need to change the follow:
Server or Data Source
and
Initial Catalog or AttachDbFilename
Now your credentials you may use any username and password that has access to the sql server express instance.
I hope this helps.

How to use ASP.NET Configuration on external SQL Server?

In visual studio there is a nice possibility to manage users and memberships for an ASP.NET site. I moved the membership data from SQLEXPRESS to a normal SQL server. The website works fine, however how do i now manage my users/profiles/etc... like I was used to in visual studio? Is it possible to tell vs2010 to 'look' into the new sql server database in stead of the apsnetdb.mdf file?
Thanks,
Erik
This is how I do it:
In your web.config file, under the connectionStrings section, name your connection string, LocalSqlServer, i.e.
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Server=123.123.123.123;Database=dbName;User ID=dbuser;Password=dbPassword;Trusted_Connection=False;" />
</connectionStrings>
Your role and membership providers, if have the connectionStringName set, change them to LocalSqlServer otherwise, the default providers "should" automatically refer to LocalSqlServer anyway.
In VS2010, I then simply go to Project > ASP.NET Configuration which will start the tool to manage users, roles etc.
HTH

asp.net| change the place webforms save user data

I am trying to change the place my webform saves the data.
What I mean is, when you open a Visual Stuido/C# Web App, its has a user login/register data.
The default data is saved in your project folder, in APP_DATA as: ASPNETDB.MDF.
What about if I want to use MSSQL Server 2008R2.
How can I change it?
Just setup a new database and change your connectionstring in the web.config:
Using SQL Server instead of ASPNETDB.mdf
<connectionStrings>
<add
name="NorthwindConnectionString"
connectionString="Data Source=serverName;Initial
Catalog=Northwind;Persist Security Info=True;User
ID=userName;Password=password"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
How to: Read Connection Strings from the Web.config File
in really server MS Server 2008R2 you must doing backup from your "home" datafiles: "in APP_DATA as :ASPNETDB.MDF"
p.s. sorry for my bad English.

Where is the database for the built in user part of asp.net MVC2?

User registration/authentication seems to be built into MVC2 but where does is the database that stores the users? It's not under data connections.
The default template uses SQL Express edition. An aspnetdb.mdf file will be stored in the App_Data directory. Look at the connection string in web.config:
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
u don't have to use aspnet_regsql.exe tool - just start your app, register new user, and then open the app_data directory in windows explorer - u will find your db file over there
Arek
The database is first created when you create the first user for the website. After that the .mdf file is in app_data folder.
If you want it to be shown in VS, you can click Project -> Show all files and then it should be visible in Solution Explorer. Right click ASPNETDB.MDF and click Include in project.
App_Data folder

Web Site Administration Tool ERRORS

I try to use Web Site Administration Tool to set up Roles in my website.
I receive an error testing "AspNetSqlProvider"
"Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider."
I used aspnet_regsql command-line utility successfully and in Visual Studio I can see in Server Explorer the database and all the tables.
WebConf is empty
What the problem could be? thanks
I've hade the same problem as you before. If you check your web.config you need something like this:
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString='YOUR CONNECTIONSTRING HERE'
providerName="System.Data.SqlClient"/>
</connectionStrings>
The important part was the remove LocalSqlServer and that the new connectionString was named the same. Hope this helps.
If you have correctly set up the web.config and still get this error I almost guarantee it is because you have an open connection to it in visual studio which blocks the connection.
Solution:
In visual studio right click the connection to the database (which probably has a 'connected' icon) and click 'close connection'
Reattempt to access the membership administration tool.
et voila

Resources