In ASP.NET Core when using SQLite database the file blogger.db is stored at the root of my project.
I was wondering where the file should go in production? I know it's a bad idea to put it the wwwroot folder.
Thank you.
I know it's a bad idea to put it the wwwroot folder.
Indeed, because otherwise, it would be potentially accessible as a static file since only those files in wwwroot may be served by Static Files Middleware.
I was wondering where the file should go in production?
The simplest way is to put it in App_Data folder.
However, there is no single recommendation on where to store it. Basically, you may put it wherever you want, once you had some restrictions on the .db file access.
For instance, you may store it at C:\data and have the access to that folder to be restricted only to the account which the application is running under.
Related
I have a scenario where I'm using 2 IIS servers running on asp.net core (nopcommerce 4.10) behind the load balancer F5 with sticky session.
Since the nopcommerce doesn't support web farm at the moment, I'm looking for a work around to share the wwwroot folder between these two servers for the images/file and pondering if it's possible to create wwwroot folder somewhere else than app root path so that these 2 app can use it (which is possible if somehow I configure dotnet core app in startup.cs to use wwwroot folder from different path).
Or alternatively share the wwwroot folder for both from one of these.
My current solution is to copy the file on another server when anything uploaded from admin side but this won't work with bundling.
I don't know nopcommerce, but one way could be to setup a network share and map it in to the wwwroot folder and give write permission on it to the application pools. The write permission is just because you wrote that you are uploading files from Admin. I guess you also have things part of the bundling that you want to include in the wwwroot folder?
Like wwwroot/my_upload_folder_share
The comment and answer from Robban1980 helped and I really appreciate it. Although I'm posting my final solution hoping, it will help someone, specifically for nopcommerce developer.
I have override the method for the in FileProvider (nopcommerce uses it for accessing file resources) to take files from my folder instead of taking it from wwwroot.
public override string GetAbsolutePath(params string[] paths)
{
var allPaths = paths.ToList();
allPaths.Insert(0, "my-folder");
return Path.Combine(allPaths.ToArray());
}
Also, I had to set read/write file permission to the folder to make it accessible via a network
I created empty project asp.net 5 in Visual Studio 2015.
Here how it looks:
As I understand from some tutorials the bin folder have to be inside wwwroot.
But there is no bin inside wwwroot and also bin folder not exists anywhere in Sensor Observation project.
Any idea why bin folder not exists inside wwwroot in my project?
The wwwroot folder is from where you serve static files (e.g. css, images, JavaScript, etc.). Files in the bin folder should never be served to the client (e.g. browser) so it should not go in the wwwroot folder.
Here is some more information on what the wwwroot should contain. Essentially:
"Enter the wwwroot folder in ASP.NET 5. The wwwroot folder represents
the actual root of the web app when running on a web server. Static
files, like appsettings.json, which are not located in wwwroot will
never be accessible, and there is no need to create special rules to
block access to sensitive files. Instead of blacklisting access to
sensitive files, a more secure whitelist approach is taken whereby
only those files in the wwwroot folder are accessible via web
requests."
The wwwroot/bin folder only used to contain one single file AspNet.Loader.dll. The AspNet.Loader.dll was/is used by IIS to load the application (which resides outside of the wwwroot folder).
The reason for this is an increase of security. With ASP.NET Core 1.0 you don't point the application entry to the folder (that contained all the *.cs files in ASP.NET 4.5), but you point it to the wwwroot folder of your application.
Now IIS don't has access to the actual application files (and allow by accidental access to maybe sensitive files). So the AspNet.Loader.dll is required to execute your application.
Other than that, there are no other binary files in wwwroot/bin nor should there be any other.
Update:
This used to be required for Helios to be run/hosted within IIS. Helios has been deprecated with beta8, because it made no sense to develop two different servers. So wwwroot/bin will always be empty for newer versions of ASP.NET Core. If you found posts or references, they most likely reference to an old beta.
Now Kestrel, IIS via HttpPlatformhandler (up to rc1-final version and ASP.NET Core Module with rc2 and newer) and self-hosting via HttpListener are the supported run modes. Though one can also use Kestrel behind an IIS.
I have a question....I'm using FileZilla to upload my eclipse project to the server. Now, it's the first time I do that and I don't know where to start. (I really don't want to do disasters)
in this image there is the composition of folders: on the left there is my project and on the right there is the server's folders.
http://img22.imageshack.us/img22/2519/jbecagca.png
In the folder WebContent I have also my 4 html files and one of these is index.html that is the page that has to be shown when I write the url of the site.
Now the question is... Where do I have to put my servlets? where my classes? where my sql dump of my database? where my html pages? where my js files?
I really have no idea.
thanks for any help!!
Go to your web host ask address for sql database you need to make a database on any of their server then it can be used you cant just use by uploading .
js files and classes will be used same hierarchy you used time of development.
If you're uploading a project, you should probably keep the project's folder structure. You should upload the whole project folder as is to the webroot, so you can access it from your browser
I have a webapplication (maven,spring,,hibernate) which contains different *.properties files which can be found within src/main/resource. Now my customer want to edit this files (e.g. change email address..) --> whats the best solution/ best practise? exclude *.properties from .war file and put it into filesystem? Jboss modules?
Can someone give me a hint?
If I were you I'd move these properties from static files to a persistent storage (i.e. DB) and then provide a UI to end user to modify their values.
Writing a custom module might work. This isn't as bad as it sounds, check out HowToPutAnExternalFileInTheClasspath.
See also migration-issues-to-jboss-7-1 and Where to put property file in JBOSS 7 or Glassflish? (Best practice)
Currently, I have my Azure Cache configuration
<dataCacheClients>
<dataCacheClient name="default">
...
inside my Web.config of my Azure WebRole. I would like to be able to easily modify the Azure Cache settings after the cspkg package has been created, i.e. I would like to move the configuration into the cscfg file.
I don't think that's possible without hand-coding all the possible configuration options of Azure Caches (and then interpreting those options and setting the configuration programmatically in the DataCacheFactory). Am I overlooking something?
in webrole (RoleEntryPoint derived class) onstart, you could overwrite web.config caching part with the relevant settings from your .cscfg file
also add eventhandler to the environment changing (RoleEnvironment.Changing += RoleEnvironmentChanging;) with e.Cancel = true so that the webrole restarts when ever you change .cscfg # the management portal
One walkarround is to rename your .cspkg file to .zip file. Then unzip the file and take a look to the files. You will find .cssx files (the larger files) representing each webrole / working role. rename to .zip and expand. Then you will find a "approot" folder. Your dlls, webconfig, etc are there. You can mess with the webconfig and zip+rename the way back.
It's not elegant at all, but sometimes is the best way to figure out what exactly are you publishing.