Creating users in ASP.NET using ASPNETDB and CreateUserWizard giving error - asp.net

I am trying to create users from ASP.NET via ASPNETDB database.
First, I created ASPNETDB using "aspnet_regsql.exe". Then I created an ASP.NET page that has only one control - a CreateUserWizard control.
Then I created an "aspnetdb.mdf" file in App_Data folder.
At run time, after entering all the fields, when I clicked on the create user button, it returns the following error:
Unable to open the physical file "C:\Users\ankit\documents\visual
studio
2010\Projects\WebApplication6\WebApplication6\App_Data\aspnetdb.mdf".
Operating system error 32: "32(failed to retrieve text for this error.
Reason: 15105)". An attempt to attach an auto-named database for file
C:\Users\ankit\documents\visual studio
2010\Projects\WebApplication6\WebApplication6\App_Data\aspnetdb.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share.
Please provide some assistance, as I am new to this. Also, some links having examples of how to use the Membership API to create, authenticate and authorize users and using ASPNETDB?
and the web.config
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=BLR-WS-180;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>

Related

ASP.NET Identity always shows error "CREATE DATABASE permission denied in database 'master'."

I created an ASP.NET MVC5 project with default template and individual user account authentication (identity).
I changed default connection string to connect my existing database that includes all tables necessary for identity.
Here is my connection string:
<add name="DefaultConnection"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;User ID=sa;Password=123456;"
providerName="System.Data.SqlClient" />
Everything works fine locally, but when I login identity in hosting, I get this error:
CREATE DATABASE permission denied in database 'master'.
Then I tried again with a new project without identity, I add an ADO.NET Entity Data Model connect to my existing database from my project and get some data to show in a view. It works fine locally and in my hosting environment.
Can someone please explain and help to fix error in case 1? Sorry my English is not good, thanks you so much.

Where does an "ASP.NET Web Application" project store user registration details?

When developing a website using a Visual Studio 2013 ASP.NET Web Application template, where does the user's information get stored when they register their details through the register.cshtml view page?
You create an MVC Web Application in VS 2013. At this moment, the database doesn't exist. But when you run the application on localhost and register a user, the database is created.
To find its name, look in web.config:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication2-20150615111350.mdf;Initial Catalog=aspnet-WebApplication2-20150615111350;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
To find its location, look in the App_Data folder:
You can use also SQL Server Management Studio for managing this database.

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

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.

ASP.NET Configuration tool provider error

I want to setup login roles for my application.
When I go to the ASP.NET Configuration Tool and Click on the Provider Tab,
I select: Select a single provider for all site management data
I get this: AspNetSqlProvider
When I click on the test hyperlink, I get this message:
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.
1) I created a ASPNETDB.MDF file in the APP_Data Folder
2) Ran the aspnet_regsql.exe tool that created the database ASPNETDB in my SQL Server
3) Edited the maching.config file for
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DIRECTORY|\App_Data\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
In DIRECTORY, I replaced DIRECTORY with the actual path: C:\Documents and Settings\Owner\My Documents\Visual Studio 2010\WebSites\myProject
Don't know what else I am missing to get the ASP.NET Configuration Tool to work
Thanks in advance for any help!
Solved the issue :
1) Created a new website and copied the database it created in the app_data folder to myproject
app_data folder.
2) Copied the differences in the webconfig sections from the website to myproject.
Configuration tool now works correctly.

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

Resources