Running ASP.NET applications under Community Server

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

Sorry, no bio is available

View complete profile

Top 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-side tasks. It has also created new classes, properties and method of working with JavaScript code. This article explores the enhancements and the various ways of injecting JavaScript programmatically into ASP.NET 2.0 pages.

ASP.NET ComboBox
The ASP.NET ComboBox is an attempt to try and enhance some of the features of the Normal ASP.NET DropDownList.

Upload multiple files using the HtmlInputFile control
In this article, Haissam Abdul Malak will explain how to upload multiple files using several file upload controls. This article will demonstrates how to create a webform with three HtmlInputFile controls which will allow the user to upload three files at a time.

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 usage and drawbacks of ASP.NET script callbacks, and briefly presents a bird's view of ASP.NET AJAX.

Using WebParts in ASP.Net 2.0
This article describes various aspects of using webparts in asp.net 2.0.

Top
 
 
 

Please login to rate or to leave a comment.

Product Spotlight