GarnetChaney.com

Search:      

New and Improved! With More Quotations and Comments from my Readers!
| What Do You Want To Say Today? Chat at Chat11 || Health || Phobias || Sleep |

Articles:

Guides

Free Tools From Garnet

Resources

My Humor


Cover of ISBN 0672323079

Cover of ISBN 0761535225

Java Programming For The Absolute Beginner

Cover of ISBN 0596003471

Programming .NET Components

Where Should A Web Application Store It's Persistent Data?

.NET Web Application Programming

Garnet's articles about Web Application Programming For .NET

For some web applications, it's fine to store data in local files on the web server hard drive. An example where this could be OK is in a document centric web application, like a wiki. Each page of the wiki could be stored as a separate file on the hard drive. If the wiki has only a single level of directory allowed (no subpages), all the pages could be stored in a single directory. For performance purposes, though, you might want to consider a custom directory structure that divides the files for the wiki into multiple subdirectories, for example, by first letter of the file name.

Where should these files be placed? What about security considerations? Should the directory containing these files go within the web server directory structure, for example, under the virtual directory for the web application? FlexWiki, a .NET based wiki originally written by someone at Microsoft takes this approach. Various subdirectories are created within a directory under the application's physical directory, and these directories are used to store various separate wikibases, according to the information in an XML configuration file.

So for example, the application might store it's data at c:\inetpub\wwwroot\flexwiki\WikiBases with separate directories such as MyWiki, and Namespaces.Second, under there. If you install this on your local machine, you might access it through a URL like this:

  • http://localhost/FlexWiki/default.aspx

Unfortunately, since the data is stored within the application directory, a URL like this will pull up internal files of the FlexWiki:

    http://localhost/FlexWiki/WikiBases/MyWiki/MyWiki.wiki

ooops! Maybe it's not too harmful to see the original text of the wiki pages, since in this case these files store nothing other than the unparsed wiki text. But it is good thing the file didn't have any secret information like passwords, or unprintable binary control information. Other wikis store a lot more information in the files that they keep for the pages of the wiki.

FlexWik is configured through the web.config custom configuration section method of .NET application configuration. So if someone changes the default settings of FlexWiki, it could be hard to guess the directory structure. You can't see this file, since IIS and .NET guard the web.config files from access via browser. There is documentation that the web.config files have an inheritance and override mechanism, but unfortunately, at least on Windows XP with IIS 5, it doesn't seem to have any effect to try and block access to the data directory by placing a web.config in the MyWiki subdirectory with an deny="*" directive. These web.configs are supposed to nest, but I haven't seen that work.

Another possibility is to use Isolated Storage for .NET applications. .NET defines isolated storage as "Isolated storage is a storage mechanism that provides isolation and safety by defining standardized ways of associating code with saved data." Typically, Isolated Storage is keyed to application and user, so that each user of the application has their own data storage area. Administrators can set allowable maximums on the size of the data storage area for users.

Isolated storage is part of the .NET security system that allows each application to have a unique storage area that is entirely isolated from other applications. It looks like a mini file system that is accessible only by that application. From the outside, it is not possible to see what kind of directories or files have been created. See the System.IO.IsolatedStorage namespace for more details.

Configuring your web application to find it's data is easy:

  <configuration>
    <appsettings>
        <add key="dsn" value="myserver"/>
        <add key="datapath" value="d:\\applicationdata\\"/>
    </appsettings>
  </configuration>

It's easy to read this:

  Dim AppSettings as Hashtable = Context.GetConfig("appsettings")
  Dim DSN as String = AppSettings("dsn")
  Dim MyAppDataPath as String =AppSettings("datapath")

For more information about related internet queries, other related articles, and to discuss this topic, please visit Where Should A Web Application Store It's Persistent Data? at Chat11.

 

Search:      

Garnet R. Chaney's Blog

Other interesting links:

Visit MySleepCenter to learn about a better night's sleep.
Visit MyWebLegalCenter when you need legal help.

Search the net for application data files for local net store web

Please link to us!
Garnet Chaney says "No information found at my web sites can replace a personal meeting with your physician about your health. Please don't just rely on the internet for your first opinion, but also seek professional help for any serious problem."

Copyright 2001-2004 By GarnetChaney.com. All Rights Reserved.

This Site Produced With SiteMaker Web Design Tool.