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.
Related
I am developing a website with the Asp.net MVC5 template. This website have obviously a database with some informations. This MS-Sql database runs on a remote VM. While coding I tested this site with the integrated IIS Express and the mentioned database.
Now I wanted to publish this website on a real IIS 10.0 Server, this IIS Server runs on the same VM as the database.
I published the website as follow:
Right click on project in VS15 > Publish > File System (Publish Method) > Copied the compiled data to the mentioned VM > In the IIS Manager I created a new website based on the compiled source data.
Now the problem:
When I try to run this website (localhost or via remote from my client) the following error occurs:
Login failed for user 'DOMAIN\MACHINENAME$'.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'DOMAIN\MACHINENAME$'.
This two connectionstrings are in my web.config, both are autogenerated from Asp.Net Frameork:
<connectionStrings>
<add name="InfoScreenContext" connectionString="data source=vsdev1972\;initial catalog=InfoScreen;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
<add name="UserProfile" connectionString="data source=vsdev1972\;initial catalog=InfoScreen;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" />
</connectionStrings>
I was searching a whole day for a solution but none of these approaches worked for me:
Adding this DOMAIN\MACHINENAME$ user to the database users
Enabled Windows Authentication in IIS Manager
Tried to edit the connection string
Granted source access for everyone
Any ideas? If u need any further informations pls contact me!
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.
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>
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
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