Calender
<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

Before starting to use Personal Web Site Starter Kit (PWS), I had a hosting package with 1and1.  I assumed, because the package supported .Net, I would be able to use 1and1 to host PWS.  Well, most of my development is for corporate environments, so I typically can run applications in Full Trust.  The limitations of Medium Trust were all new to me.

I was forced to learn a little bit about Medium Trust because PWS would sporadically generate an Exception when using 1and1 Hosting...

Security_Exception_PWS

Here is part of the stack trace exception, "System.Security.Permissions.FileIOPermission"...

Stack_Trace_PWS 

Here are some links that were helpful for me when learning about ASP.Net and Medium Trust:

How To: Use Medium Trust in ASP.Net 2.0

Medium Trust ASP.NET Applications

Hosting ASP.NET Applications in Medium Trust

Security Exceptions

Medium Trust Issue in ASP.Net 2.0

I knew my exception was related to File IO, but it was sporadic/inconsistent and the code was not doing anything special.  I saw in the Stack Trace that the Site Map Provider was involved. 

To try and work around the exception, I wrote a custom provider that derived from the XmlSiteMapProvider and overrode the IsAccessibleToUser method so that it did not access the file system.  This seemed to reduce the frequency, but the problem was not gone. 

Next, I set SecurityTrimmingEnabled to false.  Again, this seemed to further reduce the frequency, but the problem was not gone.  I read that the XmlSiteMapProvider monitors the file system for any changes to the XML file.

At this point, I was going to lose a lot of functionality, so I decided to look for another place to host my application.  I checked out GoDaddy.com.  Here is what each said about Trust level..

1and1 FAQ: Restrictions in hosting ASP.Net applications

Godaddy FAQ: What Is Medium trust level and how does it affect my hosting account?

 

I have since moved to GoDaddy without any problems.

My initial interest in the Personal Web Site Starter Kit (PWS) was the photo gallery functionality that was included.  But I have found a little time here and there to make some minor customizations.

First, if you are just starting to use PWS, here are some links for key background information...

Personal Web Site Download

Introduction to the Personal Web Site Starter Kit

Extending the Personal Web Site Starter Kit

 

Second, here are the minor customizations I have done and supporting links...

Convert Personal Web Site Starter Kit to Web Application Project (WAP): I am much more familiar and comfortable with WAP development model, so making this change was a must.  The WAP model is similar to the way things worked with Web Projects in Visual Studio 2003.

Use SQL Server 2005 with Personal Web Site Starter Kit: This was necessary because my and many other hosting providers do not allow SQL Server Express Edition.

Customizing Personal Web Site Starter Kit to Save Photos to the File System: This was needed to take advantage of my available hosting space.

Other Small Customizations: Added category attribute to the albums; Modified Handler.ashx to allow for direct file downloads of original image files; Basic integration with BlogEngine.Net and Slide.Show (cool Silverlight application), which I can detail in a future entry.

 

If you are not into doing customizations yourself, I have come across a number of enhanced versions of PWS that are available...

http://www.willyd.ca/Default.aspx

Extended Personal Web Site Starter Kit

Extended Personal Web Site Starter Kit on CodePlex

http://www.edream.org/BlogArticle.aspx?RecordID=108 

I know that others have faced the same problem as me when it comes to using Personal Web Site Starter Kit (PWS) with their hosting provider because of limited database space.  I have used 1and1 and GoDaddy and both of them offer a small amount of space within the included SQL Server database(s), but an abundance of file system space.  The photo albums were my primary reason for using PWS, but I did not want to spend a lot of time making it useable.  I ended up making some quick & dirty modifications to the PWS code to save the image files to the file system instead.  The various sizes of the photos are all saved to the file system as shown:

 photo listing

Here are the changes I made:

  1. Add a "Photos" folder to the root of the application.  This is the folder where the photo files will be stored.  (You will need to set Write permissions on this folder.)
  2. In the "Personal" database, delete the Tables ("photos", "albums") and all the Stored Procedures.  Then, run the modified "personal-add.sql" script below.  This modified SQL script will create new tables without fields for the actual files and new procedures modified as needed because the photos are being saved to the file system.
  3. Replace the "PhotoManager.vb" file with the one below. This modified class has the necessary changes to handle managing photo files on the file system, rather than in the database.
  4. Replace the "Handler.ashx" file with the one below.  This modified class has a single change to explicitly close the Stream object which can cause problems if a photo is being deleted.

Modified_personal-add.sql (3.41 kb)

Modified_PhotoManager.vb (13.79 kb)

modified_Handler.ashx (1.87 kb)

 After completing this, I found this post with another set of modifications that it looks like it uses a little different approach.

This is my first entry in the blog.  It was a little bit of an effort to get it installed and configured the way I want along with Personal Web Site Starter Kit.  But now that it is done, I am happy with the set up.