[Home]Where Should Data Be Stored For A .NET Web Application

Contents | (Visit Preferences to set your user name.) | Related To Where Should Data Be Stored For A .NET Web Application | RecentChanges | Preferences | Index | Login | Logout

Featured: Featured Stories | Picture Gallery

State Of Virginia | State Of Hawaii
Google
Chat11.com Web Bible11.com MyBibleCenter.com
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

Subjects > Computers > Software > Programming > Web Application Programming For .NET
By Garnet

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?Create, 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?Create with separate directories such as MyWiki?Create, 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?Create:

     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?Create is configured through the web.config custom configuration section method of .NET application configuration. So if someone changes the default settings of FlexWiki?Create, 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?Create 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?Create 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>

NOTE: The appSettings tag is case sensitive. If you use appsettings instead, you'll get this error from the .NET framework:

   Parser Error Message: Unrecognized configuration section 'appsettings'

It's easy to read this:

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

It's even easier to read the datapath from C#:

  string MyAppDataPath?Create= System.Configuration.ConfigurationSettings?Create.AppSettings?Create["datapath"];	

Some google queries I tried:

See also:


Could not find Programming/BottomAd1?Create

Search for books about:

/BottomAd1, AppSettings, Computers, ConfigurationSettings, FlexWik, FlexWiki, Garnet, GetConfig, InProc, IsolatedStorage, MyAppDataPath, MyWiki, Programming, Software, WikiBases

Search The Net:
Garnet
Computers
Software
Programming
FlexWiki
WikiBases
MyWiki
FlexWik
IsolatedStorage
AppSettings
GetConfig
MyAppDataPath
ConfigurationSettings
InProc
/BottomAd1

Contents | (Visit Preferences to set your user name.) | Related To Where Should Data Be Stored For A .NET Web Application | RecentChanges | Preferences | Index | Login | Logout
Edit this bookstore.mybiblecenter.com page | View other versions
Last edited April 8, 2007 2:54 am (diff)
Search:
Sign up for PayPal and start accepting credit card payments
instantly.
Bobsgear - Get A Free Enterrpise Wiki Space!
Review: The Bobsgear Project was started to develop a variety of Confluence plugins. This installation of the Confluence Enterprise wiki includes flexible attachments, many Confluence plugins, personal blogs, interesting articles, and more. Bobsgear already has spaces related to politics, art and photography wiki, technical issues wiki, ediscovery wiki, health, Christian theology and Sabbath School wiki, the bible, book reviews, and quotations. Bobsgear allows free signup, and invites anyone to create a free hosted Confluence wiki space.


NEW USERS CLICK HERE! for a quick introduction to Wiki.

 

 Interested in Medicines For Sleep Apnea?
3476 total hits since 10/2007
Recently accessed pages: 2006 Wiki Tour Of Chat11 30 Second Quick Wiki Tutorial Ants Book The Strange Case Of The Walking Corpse Books And Information About The New Age Cicada Noise Guest Book Application For .NET Using Visual Studio Handbook For Lent - The Discipline Of Lent How To Create A CGI Executable That Is A .NET Console Application Michael Savage Show Microsoft Office Update EULA Molded Stone More Information About Prediction Guru And FarSight NewUsersGuide Pope The Mating Of Fish Where's That Share Where Is Javax.Servlet.Http.HttpServletRequest

Elapsed:0