.NET Membership - asp.net

Hi I am trying out the membership features for .NET and I am using the ASP.NET Web application Administration Tool. My question is where is the user data being stored? I checked my databases and I cannot find it anywhere. I also tried to look for any information within Providers in the admin tool but I still could not locate a path. Can someone help me out? Thanks.
[EDIT]
Nothing is in the App_Data folder.
Also I was wondering when I right click App_Data and try to add a database, there is no option to do so. (Add New Item).

Look for a file called ASPNETDB.MDF in the App_Data folder of your web application project. That's a SQL Express database file.
Edit: Try looking in the App_Data folder in Windows Explorer. It may be on the disk but not showing up in the project inside of Visual Studio.
https://web.archive.org/web/20210513220018/http://aspnet.4guysfromrolla.com/articles/120705-1.aspx

I think, it would create a database by name aspnet by default.
Check it :)

It's saved in a database file under your ASP.NET application's App_Data folder.
You can configure it by aspnet_regsql.exe tool to include in your sql server instance :
aspnet_regsql.exe -E -S localhost -A mr

Check your web.config for the connection string to the database. If it's sql server then there will be a bunch of tables prefixed with 'aspnet_' or something very similar.

If you need to create the tables and stored procedures for the membership/roles provider you can open a Visual Studio command prompt (check your Start menu) and run aspnet_regsql. The .exe is also under the %WINDOWSDIR%\Microsoft.NET\Framework\v2.0.50727\ directory.
It'll enable you to select a database from a running of Server and create everything you need to be getting on with.

Related

How to create an installer for ASP.net website with NSIS

I want to create an installer for ASP.net website.
Can I use NSIS to create an installer for my web application.
So I wanted to do followings through the installation wizard.
I need to install required databases in client computer.
I need to update the connection string in web.config file based the database.
I need to create ODBC connection and save their names in my project config file.
I need to create an application in application pool of IIS.
I need to host my project in IIS.
Can someone please let me know is it possible to do those things with NSIS?If possible how can I do it?
Thanking you.
There is no exact answer for you.
You need to create a customized installer with custom pages - but it is up to you how the custom pages look like and what they do.
You can achieve this with NSIS (even with Inno Setup which is a little easier to user) but we cannot post tutorial for you.
What you need to do is to start with simple installer (default one) and add custom pages to it. It page represent some functionality:
settings database connection values
writing configuration
creating app pool
setting IIS (there are some NSIS plug-in for working with IIS)
copying files etc.
Start with some NSIS example and add more and more functionality in it until it meets your requirements.

How to extract the database file when using SQLExpress in Visual Studio

I have made my database in SQLExpress and its a master database . I would like to create a CD for my project so need the database file. I am not able to find that file please suggest a solution
thanks!
Your database files would be in the App_Data folder by default if you are using SQL-Express provided with Visual Studio.
You can generate an SQL script of your database which can be used to re-create it in different db server by running the script again. For this right-click on the database in the Server Explorer and select Publish to Provider.
You'll need the .mdf and .ldf in the SQL Server installation directory, but if you've created everything in the master database, I'd recommend creating a different database and moving everything there instead. The master db shouldn't be used for stuff like that.

How to use aspnetdb database with an asp.net website

I have created a website using asp.net 3.5.
And now I have added member support to it using Membership API and aspnetdb database.
And I have done all testing on my local machine.
Now, what issue needs to be considered with respect to aspnetdb while uploading this site to the server. ie; how this database will be available on the server side ?
Note : This is my first ever website.
I was just looking for an answer to this myself.
I've found the following that might help you:
http://www.studiocoast.com.au/knowledgebase/article-6-aspnet-using-sql-server-instead-of-aspnetdbmdf.aspx
"When developing applications in
ASP.NET 2.0, the default option for
roles and users is to use a local SQL
database in the App_Data directory.
This works fine locally, but will
bring up an error when uploaded to a
production server. To fix this the
ASP.NET membership information needs
to be stored in a dedicated SQL Server
database."
"ASP.NET includes a program called
Aspnet_regsql.exe which you can run
locally to configure your database.
More information on the program can be
found here:
http://msdn2.microsoft.com/en-us/library/ms229862.aspx"
Look in your C:\Windows\Microsoft.NET\Framework\v2.0.50727\ folder for the file InstallMembership.sql.
Thats the SQL script to create the database you need.

ASP.NET MVC wants me to store my SQL Server database files in the App_Data folder -- should I?

When creating a new database with SQL Server Express 2005, the database files (.mdf and .ldf) get stored in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data by default.
However, with the tutorials I've seen for ASP.NET MVC (e.g., Nerd Dinner), it seems to be common practice to keep the database files in the ASP.NET project's App_Data folder.
Questions
Is there any significance to the App_Data folder, or is it just a convenient place to store database files if you happen to use Visual Studio's designer to create a new database?
Will there be any negative repercussions if I don't use or even delete the App_Data folder?
Update
One thing I'm still not getting. If you have a production database on the server, why would you even want to replace this database with what is in App_Data. Wouldn't you normally just want to have update scripts that you run on the production database when you release a new version of the app? Even for initial deployment, I'd rather script database creation than physically copy over the files. Also, with SQL Server (Express) databases, copying is not enough. You have to detach the database to manipulate the files then reattach when you are done.
So, I have to say, the point of App_Data still escapes me. Can someone enlighten me?
You can delete App_Data without any negative repercussions, but when it exists (by folder name) inside an ASP.NET website then it has the special website power of disallowing direct linking to download its contents - this is a security feature to protect your database from being downloaded directly over the web (e.g. by a web browser) even though it exists in the website. However your application can still access the files in the App_Data folder just as it accesses other website content.
Microsoft states it as:
Note: The content of application
folders, except for the App_Themes
folder, is not served in response to
Web requests, but it can be accessed
from application code.
Microsoft describes their special ASP.NET folder structures including App_Data here.
There are a number of advantages of placing database files in the App_Data folder:
As some have mentioned, that folder is secure from people browsing it directly on the web. This is also true of placing the database in folders outside of your web site, though.
You can "xcopy deploy" your application by copying the entire folder from your local development machine to your hosting web site.
Various components in Visual Studio can offer extra assistance in building your application by having your database files there. For example, you can double-click on a SQL Server Express MDF file and have it automatically open up in Server Explorer so that you can change the database's schema or view its data.
There is absolutely no need to use the App_Data folder. It's just a convenient place to keep your database files together with your site. The decision to use it or not is more a matter of preference / policy than anything else.
yes, when you are simply using an express database which will exist within your webroot it is best to use the app_data folder. The primary reason is that the asp .net isapi implicitly knows not to fulfill any requests for files from this directory. The same goes for the app_code folder. There is no stipulation that you have to but its good practice to be prudent.
You can also store sensitive xml,access dbs and any other data files in here for added security.
I've only ever used it for local development before pointing the web.config at a SQL server instance rather than the db files.

ASPNET user does not have write access to Temporary ASP.NET Files

I get the following error when running my Visual Studio 2008 ASP.NET project (start without Debugging) on my XP Professional box:
System.Web.HttpException: The current identity (machinename\ASPNET) does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.
How can I resolve this?
Have you tried, the aspnet_regiis exe in the framework folder?
I had the same problem. This is what I did:
Go to c:\windows\microsoft.net\framework\v2.0.50727
right click on "Temporary ASP.NET files"
Security tab
Select "Users(xxxxxx\Users) from Group
check "Write"
OK
Either grant that user the level of access to that directory, or change the identity that the application's application pool runs under - in IIS Manager, determine what App Pool is used to run your application, then in the App Pool section of IIS Manager, look at the properties for that pool - the tab you want is "Identity" I think (this is off the top of my head).
You can set it to another user account - for example, Crystal Reports .Net requires update and delete access to C:\Temp - so we have a "webmaster" user, with administrator access, and use that identity for those applications.
You can try to fix it using the automated regiis utility aspnet_regiis.ext available in c:\windows\microsoft.net\framework\v2.0.50727
Otherwise just manually add the needed file permissions as noted in the error.
you can right click the Visual Studio & select run as administrator.
I had this problem when trying to build a Web Deployment Project (*.wdploy).
Simply creating the folder on the framework path solved the error.
Just because the most recent answer is 5 years old, what had to be done in our environment was to delete the app, app pool and recreate them.
We evidently have some security under the hood with recent changes to it.
Doing this re-created a folder in Temporary ASP Net Files with all the correct permissions. Why the one site I happened to just get from source control, rebuild, etc. failed this way, no idea. 2 others recently set up where Get Latest Version was downloaded, rebuilt, etc. they just worked.
But ripping out the app, app pool and just recreating them with the same IIS permissions as the 2 other known working sites recreated all the needed objects and now it all works.
Make sure the ASPNET user has permission to write to that folder. Right click on the folder, Properties, Security tab.

Resources