This project is read-only.


Microsoft WebMatrix provides an easy way to get started with web development, and together with new Razor syntax for ASP.NET Web Pages it includes everything you need to get your web site up, running and integrated with many other sites and networks, in a short period of time. The WebMatrix helpers are designed to make your life easier when creating web sites. They provide you a simple and consistent way of performing common web development tasks that otherwise would require a great deal of custom coding. With a few lines of code you should be able to secure your web site using membership, store information in Windows Azure Storage, integrate your site with Facebook, among others things.

When offering services via a web site, a popular way to attract first time users is to offer a free version of the software that has limited functionality. A good way to convert that non-paying customer into a paying customer is to offer more functionality and features beyond what is available in the free version and allow the transition between versions to be seamless. This business model of delivering “basic services for free, while charging a premium for advanced or special features” is known as the Freemium business model.

The Freemium Applications Helper for WebMatrix provides an easy way to apply the Freemium model into your WebMatrix site. Using different user groups (or roles), it allows you to easily enable or disable features on your pages depending on the stock-keeping unit the user has paid for. It also provides an easy way to administrate the Freemium model using a stock-keeping unit/features matrix to manage which features are available in each SKUs.

Note: Stock-Keeping Units are the way to identify the different versions of the products you’re offering through your Web application. Each SKU has an associated set of features, only available for those users who have purchased the SKU.

Getting Started in 60 Seconds

The helper includes the following files:

  • The Freemium.cs file located into the App_Code folder of your WebMatrix site.
  • A Freemium folder, which includes all the Freemium model administration pages to create and edit stock-keeping units and features. Notice these pages are prepared to be used with a layout page, as explained in this WebMatrix tutorial. And also they are prepared so that only users on the "admin" user group have permissions to enter these pages.

To use the Freemium Helper follow these steps:

  1. Download the helper package and extract its content in the root folder of your WebMatrix site.
  2. This helper requires that you setup web site membership with the WebSecurity WebMatrix helper, as explained in this WebMatrix tutorial. Make sure the registration page is only accessible to the site administrator.
  3. Optionally, you can have pages in your site for administrating user accounts and user groups (or roles) to avoid editing your database manually. You can take a look at an example for these pages in the Freemium Sample (see below).
  4. Add the following line to the _AppStart.cshtml page of your WebMatrix site, replacing the "your-database-name" placeholder, with your web site database name. This helper requires that you create a database for your web site. You can find instructions on how to do this in this WebMatrix tutorial.
        Freemium.Initialize("your-database-name", createBaseDataSet: true);
    The second parameter in true indicates that a base set of stock-keeping units and features will be created automatically in this database.
  5. Add the following lines to display the SKU/Features matrix in a page:
  6. Create a new user in your Web site and then create two new user groups (or roles): "silver" and "gold". Put the new user into the "gold" role. You can do this manually, by editing the webpages_Roles and webpages_UsersInRoles tables from your database as explained in this WebMatrix tutorial.
  7. Add the highlighted lines from below in the page where you want to disable some feature for free users, for example "feature 3", which is only enabled for "gold" users.
    <!DOCTYPE html>
            @if(Freemium.IsFeatureEnabledForCurrentUser("feature3")) {
              <p>This text will only be displayed for users in the "gold" stock-keeping unit.</p>
  8. Test how the disabled feature, "feature 3" is only enabled for the users in the "gold" group (or role) you've created (that is, users who have purchased the gold stock-keeping unit).

Documentation and Samples

Helper reference is available here. Optionally, you can download a sample WebMatrix web site where you can see the helper in action and also get examples of pages for managing users and groups of your Freemium model. To download and run it with Microsoft WebMatrix, follow these steps:

  1. Download the sample site from the Downloads section. Extract the contents and open the folder in WebMatrix.
  2. Click the Run button to open the sample.
  3. Browse to the Login page, enter the administrator password as shown there and then browse to the Manage Site page.
  4. In the Role Management section, see the associated stock-keeping unit for each role.
  5. Click Freemium Admin and play with the Freemium Model!

More Info

Don't miss the helper's getting start screencast.

You can find more information about the Freemium Business Model in

Learn more on WebMatrix, ASP.NET Web Pages and the Razor Syntax with the WebMatrix tutorials.

Last edited Jan 7, 2011 at 2:02 PM by jsenior, version 7