Reputation: 623
I usually code in Notepad++ and I'm trying to learn how to use databases. I've created a database in WebMatrix 3 and saved it in the standard saving folder called "App_Data", can it be stored here and still accessed if all my other files are in a different location? Or do I need to save it among my other files? If this question is stupid I apologize but I can't seem to find an answer elsewhere.
Upvotes: 1
Views: 314
Reputation: 1372
The App_Data folder is not a folder like any other folder of your site and using it for storing databases is not only a convention.
Anything stored in App_Data is protected and, as reported by Mike Brind in his article, "Anything placed in App_Data is protected by ASP.NET, and requests for items within it are met with a 403 - Forbidden error message."
Edited
You can access its content through your application, but not make a direct download. A way for downloading files stored in App_Data with WebMatrix could be a simple handler like this (download.cshtml)
@{
if(!Request["filename"].IsEmpty()){
var filename = Request["filename"];
Response.Buffer = true;
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=" + filename);
Response.ContentType = "text/plain";
Response.WriteFile("~/App_Data/" + filename);
}
}
calling it with a link tag like
<a href="~/download?filename=myFile.txt">Download my file</a>
Upvotes: 1
Reputation: 2522
It can. It is just a "best" practice to save items in "standard" folders, making it easier for other developers to find things when they work on the project. You can attach any of the database (if sql) to a engine on your machine, etc.
Upvotes: 1