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.

protected void Page_Load(object 

sender, EventArgs e)
{
CommunityServer.Components.User currentUser =
CommunityServer.Components.CSContext.Current.User;
Label1.Text = currentUser.Username;
}

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:

<authentication mode="Forms" />

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.

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


JavaScript with ASP.NET 2.0 Pages - Part 1
ASP.NET 2.0 has made quite a few enhancements over ASP.NET 1.x in terms of handling common client-si...
ASP.NET ComboBox
The ASP.NET ComboBox is an attempt to try and enhance some of the features of the Normal ASP.NET Dro...
Upload multiple files using the HtmlInputFile control
In this article, Haissam Abdul Malak will explain how to upload multiple files using several file up...
JavaScript with ASP.NET 2.0 Pages - Part 2
ASP.NET provides a number of ways of working with client-side script. This article explores the usag...
Using WebParts in ASP.Net 2.0
This article describes various aspects of using webparts in asp.net 2.0.

You might also be interested in the following related blog posts


ASP.NET MVC: DevExpress Mail Demo read more
New article: How to detect and avoid memory and resources leaks in .NET applications read more
Announcing the Microsoft AJAX CDN read more
Application Identifiers (AI) for EAN-128 barcode generation read more
Understanding Reverse Proxy Servers and the Mailman read more
Adding users to a TFS project when youre not on the domain read more
Multi-Targeting Support (VS 2010 and .NET 4 Series) read more
Speaking at the Portland Area .NET User Group on Tuesday Sept 1st read more
ASP.NET MVC - Is WebForms the VisiCalc of Web Development? read more
Comments on my recent benchmarks. read more
Top
 
 
 

Please login to rate or to leave a comment.

Product Spotlight