Published: 16 Apr 2007
By: Tod Birdsall

In this article you will learn how to successfully setup your own ASP.NET 2.0 application to run as a virtual directory under the Community Server 2.1 website.

Introduction

I have been working with Community Server for some time now and most of my installations require that Community Server integrates with existing applications. This article will walk you through the process of setting up your own ASP.NET application under the Community Server installation.

Step 1: Setup your Community Server website

There are multiple ways to complete this step. For the purposes of this article, I will assume that you have downloaded the Community Server 2.1 (Web Install) - ASP.NET 2.0 package and followed their instructions on setting up a database. I will also assume that you placed the Community Server web directory at C:\myCS\web.

Create a new website called myCS in IIS and point it to the home directory of C:\myCS\web.

Step 2: Create your Web Project

Open Visual Studio 2005 and create a new website project. Be sure to give it a creative name like "del.icio.us" or "Delicious_Library". Seeing that those names are already taken I will call the example project "vicious". I will assume you created this project under C:\viciousProject\viciousWeb.

Add the following references to your newly created web project:

  • CommunityServer.ASPNet20MemberRole.dll
  • CommunityServer.Components.dll
  • CommunityServer.Reader.dll
  • CommunityServer.SqlDataProvider.dll
  • CommunityServer.Blogs.dll

The above files can be found in the C:\myCS\web\bin folder. Adding the above files as references will pull in all dependant DLL's. If you now look in the C:\viciousProject\viciousWeb\bin folder, you will notice that several other DLLs have been added automatically, in addition to the four indicated above.

Copy the following files from the root of your CS website (C:\myCS\web) to the root of your web project:

  • communityserver.config
  • SiteUrls.config

Step 3: Create the Virtual Directory

Open IIS and browse to the Community Server site you just created (myCS). Right click myCS to open the context menu. Click on New > Virtual Directory.

At this point a helpful Virtual Directory Creation Wizard window should display. When prompted, type vicious for the alias, browse to C:\viciousProject\viciousWeb, and set the Access Permissions to allow Read and Run Scripts.

Step 4: Add some Community Server code

Let's add some code to your web project that will give us a quick taste of what we can do with an app that is properly configured to run as a virtual directory of a Community Server site.

If your web project did not automatically create a Default.aspx file in the root of the project for you, then you should create one now. Open the Default.aspx webform and add a Label control to the page. Next, open the Default.aspx.cs and add the following code to the Page_Load function.

The above code will display the username of the currently logged in user when the page loads. For this to work properly, your application's authentication mode must be set to "Forms" in your Web.config. The line should like similar to this:

Step 5: View Frankenstien's Monster

Browse to your functioning (hopefully) Community Server 2.1 web site. After you have logged in, browse to the /vicious subdirectory which contains your Default.aspx page. Once the page finishes loading, you should see your Community Server username displaying on the page.

Summary

In this article you have seen how to create an asp.net application under the Community Server application. I hope that you are able to use this article to assist you with harnessing some of the features of Community Server in your own ASP.NET 2.0 applications.

<<  Previous Article Continue reading and see our next or previous articles Next Article >>

About Tod Birdsall

Like many software developers, my love of video games kindled an interest in programming. I eventually realized that playing games and writing code for games are two completely different things and have resigned myself to business application programming. I enjoy writing and sharing knowledge wit...

View complete profile here.

Other articles in this category


ASP.NET MVC Dynamic Model Binding
Dynamic model binding enables a single action to handle multiple forms.
Implementing Website Pinning in ASP.NET
Learn to enable website pinning features of IE9 on Windows 7 for your ASP.NET websites.
Building a YouTube-like Video Playing Site Using ASP.NET Techniques - Part 3
In this final part of this series, we are going to discuss how to make the users play their selected...
Using HTML5 Web Storage in ASP.NET
HTML5 Web Storage provides a streamlined data storage mechanism that allows developers to store data...
Running multiple websites in a single hosting space
Develop a solution that supports multiple websites in a single hosting space and database.

You might also be interested in the following related blog posts


Session State Not Working? Check Your Web Garden! read more
Adding users to a TFS project when youre not on the domain read more
My History of Visual Studio (Part 8) read more
Multi-Targeting Support (VS 2010 and .NET 4 Series) read more
Web Deployment Tool has gone RTW read more
Three IIS Concepts ASP.NET Developers Should Know read more
Understanding Reverse Proxy Servers and the Mailman read more
Enterprise Architecture Meta-model, size doesn't matter read more
Moving MOSS Intranet to a New WFE read more
PHP Linux Windows ASP.NET Performance Redux ! read more
Top
 
 
 

Please login to rate or to leave a comment.