Getting Started with the Development Environment Using Microsoft Content Management Server

Exclusive offer: get 50% off this eBook here
Enhancing Microsoft Content Management Server with ASP.NET 2.0

Enhancing Microsoft Content Management Server with ASP.NET 2.0 — Save 50%

Use the powerful new features of ASP.NET 2.0 with your MCMS Websites

$22.99    $11.50
by Lim Mei Ying Spencer Harbar Stefan Goßner | April 2010 | .NET Content Management Open Source

In the previous article by Spencer Harbar, Lim Mei Ying, and Stefan Gobner, authors of Enhancing Microsoft Content Management Server with ASP.NET 2.0, we learnt how to install and configure MCMS 2002 Service Pack 2 (SP2), along with SQL Server 2005 and Visual Studio 2005 on a single developer workstation. In addition, we also covered the changes to the SP2 development environment and a number of tips for working within it. In this article, which is the third article of the article series, we will spend some time getting familiar with the MCMS Service Pack 2 development environment for Visual Studio 2005, which is slightly different from what we are used to with previous versions of Visual Studio. In addition we will create custom Visual Studio 2005 templates to overcome some of the issues that are present with the templates that shipped with MCMS SP2.

Visual Web Developer Websites

The key difference between developing MCMS applications with Visual Studio .NET 2003 and Visual Studio 2005 is that ASP.NET applications (and therefore MCMS applications) are now built using the Visual Web Developer component of Visual Studio 2005. Visual Web Developer introduces a new "project system", which no longer uses the project (*.csproj) files and simply accesses web applications via HTTP or the file system.

In Visual Studio .NET 2003, MCMS applications were created by choosing the MCMS Web Application project type. This project type was effectively a regular ASP.NET web application project with some modifications required by MCMS, such as additional references, the web authoring console, and modifications to the web.config. In Visual Studio 2005, developing web applications has been separated from developing other project types. The feature to develop a web application has been moved into the Visual Web Developer component.

To reflect this design change, you are no longer using New Project but New Web Site from the File menu in Visual Studio 2005 to create a new website.

Visual Studio 2005 ships with several website templates. The installation of the developer tools for MCMS extends the list of website templates with three additional templates: MCMS Empty Web Project, MCMS Web Application, and MCMS Web Service. These templates are actually modified versions of the similarly named standard templates shipped with Visual Studio 2005.

Creating an MCMS Web Application

Let's create an MCMS web application using Visual Studio 2005.

  1. Open Visual Studio 2005.
  2. From the File menu, choose New, followed by Web Site
  3. In the New Web Site dialog, select the MCMS Web Application within the My Templates section.

    If the MCMS Web Application template does not appear in the My Templates section, the MCMS Visual Studio 2005 templates have not been correctly installed. Please refer to the Visual Studio Templates section of Article 1 for installation details.

  4. In the Location combo box, select HTTP, and in the textbox, enter http://localhost/mcmstest.

    MCMS applications have to be created using a local installation of IIS and do not support being created using the file system, which makes use of the built-in Visual Web Developer Web Server.

    Note that the New Web Site wizard will not prevent you from configuring an invalid website using the File System and Visual Web Developer Web Server.

  5. In the Language combo box (shown in the following figure), select Visual C#, and click on OK.

    Getting Started with the Development Environment Using Microsoft Content Management Server

    If you wish, you can also choose VB.NET. The samples in this article series are all written in Visual C#.

  6. Visual Studio 2005 will create your project and initialize the MCMS Template Explorer. When it's done, you will be presented with an MCMS website with the basic foundation files.

    Getting Started with the Development Environment Using Microsoft Content Management Server

    The MCMS Template Explorer within Visual Studio 2005 logs on to the MCMS repository using the credentials of the currently logged-on user. If this operation fails, check your MCMS Rights Groups configuration. The Template Explorer does not allow you to specify alternative credentials.

  7. Click on the MCMS Template Explorer tab at the bottom of the Solution Explorer, and note that the Template Gallery is accessible.

    Getting Started with the Development Environment Using Microsoft Content Management Server

    If you don't see the Template Explorer, it is likely you didn't select HTTP in the Location combo box in step 4. You may also not see the Template Explorer if you are using a locale other than US English, in which case you need to install hotfix 914195 as detailed in Article 1.

  8. Click on the Solution Explorer tab at the bottom of the MCMS Template Explorer, and click on the Refresh button. Notice that unlike the web applications from ASP.NET 1.x days, the 'CMS' virtual directory is now part of the website.
  9. If you examine the contents of the website, its references, and web.config file, you will see that the necessary MCMS files and configuration changes have been added.

Checking the Website Configuration Settings in IIS

We can verify that Visual Studio 2005 has configured the MCMS application correctly by using the Internet Information Services snap-in. First, let's ensure that the mcmstest website is indeed running on ASP.NET 2.0.

  1. From the Start Menu click on Run, enter inetmgr in the Run textbox, and click on OK.
  2. In Internet Information Services, expand the tree view to display the mcmstest application.
  3. Right-click the mcmstest application and click on Properties.
  4. Click the ASP.NET tab and note that the ASP.NET version is correctly configured as 2.0.50727.

    Getting Started with the Development Environment Using Microsoft Content Management Server

    When developing on Windows Server 2003, the Virtual Website root must run in the same worker process (that is Application Pool) as all MCMS applications so that the MCMS ISAPI Filter can work as expected. This filter cannot route requests across worker-process boundaries. In effect this means that all MCMS applications will share the same ASP.NET version, as ASP.NET does not support side-by-side execution of different versions inside the same worker process. This is not necessary with IIS on Windows XP as it does not use Worker Process Isolation mode.

Next, we will check the authentication settings. For now, we will configure the website to use integrated Windows authentication. Only users with a domain or local user account will have access to the site. Later in Article 6 we will show alternative authentication methods such as Forms Authentication.

  1. Click on the Directory Security tab followed by the Edit... button, and note that the permissions are correctly inherited from the Virtual Web Site settings. In this example, we will use integrated Windows authentication.

    Getting Started with the Development Environment Using Microsoft Content Management Server

    Note that we configured the Virtual Web Site to use Windows authentication in Article 1. Authentication methods can be configured on a per-application basis.

  2. Click on Cancel and close Internet Information Services.

Developing MCMS Web Applications

We are now ready to get started on developing our ASP.NET 2.0-based MCMS applications. There are a number of quirks with the MCMS web application templates, which we need to bear in mind during development.

  1. Switch back to Visual Studio 2005.
  2. In Solution Explorer, right-click on the website (http://localhost/mcmstest), and click on New Folder.
  3. Enter Templates as the folder name.
  4. Right-click on the Templates folder and click on Add New Item…
  5. In the Add New Item dialog, select the MCMS Template File item and enter Basic.aspx in the Name textbox. Click on Add.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  6. The new Basic.aspx template file is created and opened in Source View.
  7. Examine the contents of Basic.aspx.

Correcting Basic.aspx

Notice that the Basic.aspx file has a few problems. Some elements are highlighted by IntelliSense "squiggles", and if we attempt to build the website, a number of errors will prevent a successful build. Let's correct the Basic.aspx template file.

  1. In the CodeFile attribute of the Page directive on line one, replace CodeFile="~/Basic.aspx.cs" with CodeFile="basic.aspx.cs"

    The MCMS Web Application New Item template doesn't recognize that our new template file has been created in a subdirectory, and therefore the CodeFile attribute is incorrect. New templates in the web root are not affected.

  2. From the Build menu, choose Build Web Site. Notice that the website now builds, but still includes a number of errors.
  3. Correct the DOCTYPE. On line 19, replace
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

    with

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. Correct the <html> element. On line 20, replace <html> with <html xmlns="http://www.w3.org/1999/xhtml">.
  5. Delete the comments on lines 4 through 17.

    The comments within an inline ASP script block (<% %>) are unnecessary.

  6. Delete the <meta> tags on lines 10 through 13.
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 8.0">
    <meta name="CODE_LANGUAGE" content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">

    These <meta> tags are unnecessary.

  7. Correct the WebControls Register directive. On line 2, replace:
    <%@ Register TagPrefix="cms" Namespace="Microsoft\
    ContentManagement.WebControls" Assembly="Microsoft.
    ContentManagement.WebControls"%>

    with

    <%@ Register Assembly="Microsoft.ContentManagement.WebControls,
    Version=5.0.1200.0, Culture=neutral, PublicKeyToken=31bf385
    6ad364e35" Namespace="Microsoft.ContentManagement.WebControls"
    TagPrefix="cms"%>

    The original Register directive is not correctly recognized by Visual Studio 2005, and prevents IntelliSense from including the cms tag prefix.

  8. From the Build menu, choose Build Web Site. Notice that the website now builds free of any errors and that the cms tag prefix is understood.
  9. Your template file should now be as follows:
    <%@ Page language="c#" AutoEventWireup="false" CodeFile="Basic.
    aspx.cs" Inherits="Basic.Basic"%>
    <%@ Register Assembly="Microsoft.ContentManagement.WebControls,
    Version=5.0.1200.0, Culture=neutral, PublicKeyToken=
    31bf3856ad364e35"
    Namespace="Microsoft.ContentManagement.WebControls"
    TagPrefix="cms"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <title>Basic</title>
    <cms:RobotMetaTag runat="server"></cms:RobotMetaTag>
    </head>

    <body>
    <form id="Form1" method="post" runat="server">
    </form>
    </body>
    </html>
Enhancing Microsoft Content Management Server with ASP.NET 2.0 Use the powerful new features of ASP.NET 2.0 with your MCMS Websites
Published: August 2006
eBook Price: $22.99
Book Price: $37.99
See more
Select your format and quantity:

Configuring the 'CMS' Virtual Directory

You may have noticed during the previous example that it takes quite some time to build the website. This is primarily due to the fact that the contents of the 'CMS' Virtual Directory are included within the project. These files provide, among other things, the Web Author functionality, and are required by MCMS applications. However, their inclusion in the project causes some problems, as the files themselves do not need rebuilding. In addition, these files will generate a large number of warnings, and in some cases when additional elements are installed (such as the excellent Telerik r.a.d. MCMS Controls Suite), prevent a successful build. Let's configure the 'CMS' Virtual Directory so that it is ignored by the Visual Studio 2005 when building the website.

  1. Open Windows Explorer.
  2. Navigate to C:\Program Files\Microsoft Content Management Server\Server\IIS_CMS.
  3. Press Ctrl+A to select all four folders, and press Alt+Enter.
  4. On the Properties dialog, click on the Hidden checkbox.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  5. Click on OK, and on the Confirm Attribute Change dialog, select the Apply changes to the selected items only radio button and click on OK.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  6. Close Windows Explorer.

Visual Studio will now ignore the content of the 'CMS' Virtual Directory when building websites, but the files will still be available to our MCMS applications. Remember to set the Hidden flag to all folders in the IIS_CMS directory if you install other third-party components into this folder in the future.

Creating Custom MCMS Application Templates

In order to save ourselves from the trouble of correcting the template file in the future, we shall create a new item template based on our corrected template. Start by checking if the Export Template item is contained within the File menu. If Export Template does not appear in the File menu, a common issue with Visual Studio 2005, take the following steps:

  1. From the Tools menu, choose Customize. In the Customize dialog, click on the Commands tab.
  2. Select the File Category and scroll the Commands list box to locate Export Template…
  3. Drag the Export Template… item onto the File menu.
  4. Close the Customize dialog.

Now we can go ahead and create our custom template.

  1. From the File menu choose Export Template…
  2. On the Choose Template Type page, select the Item template radio button, and click on Next.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  3. On the Select Item To Export page, select the Basic.aspx checkbox, and click on Next.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  4. On the Select Item References page, click on Next.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  5. On the Select Template Options page, enter MCMS SP2 Template File in the Template name textbox, and a description (if you wish) in the Template description textbox. Deselect the Display an explorer window on the output files folder checkbox, and click on Finish.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  6. The new item template is created.
  7. From the Solution Explorer in the Templates folder, right-click on the Basic.aspx file and click on Delete, followed by OK.
  8. From the Solution Explorer in the Templates folder, right-click on the Basic.aspx.resx file and click on Delete, followed by OK.
  9. Right-click on the Template folder and click on Add New Item…
  10. In the Add New Item dialog, select the MCMS SP2 Template File item, enter Basic.aspx in the Name textbox, and click on Add.
  11. From the Build menu, choose Build Web Site. Note that the website build succeeds.
  12. From the Solution Explorer, double-click on the web.config file. Notice that the <compilers> element is highlighted with a warning by IntelliSense.
  13. Delete lines 24 through 26, and save the web.config file.
    <compilers>
    . . .
    </compilers>

    The compiler element is not required and is no longer a valid entry within the compilers configuration section with ASP.NET 2.0.

Now that we have corrected all the problems with our MCMS SP2 application, let's build a Visual Studio 2005 project template.

  1. From the File menu choose Export Template…
  2. On the Choose Template Type page, select the Project template radio button, and click on Next.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  3. On the Select Template Options page, enter MCMS SP2 Web Application in the Template name textbox, and a description in the Template description textbox. Deselect the Automatically import the template into Visual Studio checkbox, and click on Finish.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  4. Switch to and close Visual Studio 2005.
  5. In the Windows Explorer window opened by Visual Studio 2005, right-click on the MCMS SP2 Web Application.zip file and click on Extract All…
  6. In the Extraction Wizard, click Next, followed by Next.
  7. Deselect the Show extracted files checkbox and click on Finish.
  8. Delete the MCMS SP2 Web Application.zip file.
  9. Double-click on the MCMS SP2 Web Application folder.
  10. Open the vwd.WebInfo file with Notepad.
  11. Replace <UserProperties CmsEnabled="1"/> with <UserProperties CmsEnabled="2"/>.

    This setting allows Visual Studio 2005 to create the 'CMS' virtual directory when our application is created. It then sets the CmsEnabled attribute to 1. It may not be necessary to change this attribute if it is already set to CmsEnabled="2".

  12. Save and close vwd.WebInfo.
  13. Open the MyTemplate.vstemplate file in Notepad.
  14. Delete line 17:
    <Folder Name="CMS" TargetFolderName="CMS"/>

    The export-template wizard automatically includes the contents of the 'CMS' virtual directory as part of the template; this step removes these files from the template.

  15. Save and close MyTemplate.vstemplate.
  16. Select all files in the MCMS SP2 Web Application folder.
  17. Right-click on the selection and click on Send To, followed by Compressed (zipped) Folder.
  18. Rename the ZIP file MCMS SP2 Web Application.zip.
  19. Right-click on the MCMS SP2 Web Application.zip file and click on Cut.
  20. Navigate to the My Documents\Visual Studio 2005\Templates\ProjectTemplates folder.
  21. From the Edit menu choose Paste.
  22. Delete the My Documents\Visual Studio 2005\My Exported Templates\MCMS SP2 Web Application folder.
  23. Open a Visual Studio 2005 command prompt.
  24. Execute the command devenv /setup and close the command prompt.

We have corrected the MCMS item and project templates which shipped with SP2, and are ready to create a simple test MCMS application based on our custom templates.

  1. Open Visual Studio 2005.
  2. From the File menu, choose New, followed by Web Site…
  3. In the New Web Site dialog, select the MCMS SP2 Web Application item, select HTTP in the Location combo box, enter http://localhost/mcmssp2 in the textbox, and click on OK.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  4. Open the MCMS Template Explorer using View | Other Windows | MCMS Template Explorer.
  5. Right-click on the Templates folder and click on New Template.
  6. Name the template Basic.
  7. In the Properties window, click on the ellipsis (…) button on the right of the TemplateFile property. If you do not see the Properties window, right-click on the template and choose Properties.
  8. In the Select File dialog, select the Basic.aspx file inside the Templates folder, and click on Select.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  9. Click on the ellipsis (…) button on the right of the PlaceholderDefinitions property.
  10. In the Placeholder Definition Collection Editor dialog, click on Add, followed by OK.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  11. Click on the Save icon at the top of the Template Explorer and click on the Solution Explorer tab.
  12. Double-click on the Basic.aspx file inside the Templates folder and click on the Design button at the bottom of the code editor.
  13. Drag and drop DefaultConsole.ascx inside the Console folder from the Solution Explorer onto the design surface.
  14. From the Content Management Server toolbox, drag and drop an HtmlPlaceholderControl onto the design surface.
  15. Click on the arrow on the PlaceholderToBind property within the Properties window, and select NewHtmlPlaceholderDefinition1.

    Getting Started with the Development Environment Using Microsoft Content Management Server

  16. From the Build menu, choose Build Web Site.
  17. From the Tools menu, choose Content Management Server followed by Web Author. Internet Explorer will open at http://localhost/channels.
  18. Click on Switch To Edit Site.
  19. Click on Create New Page.
  20. In the Template Browser, click on Templates followed by the select icon for the Basic template. The new posting opens in Edit mode.
  21. Enter some text into the HTML placeholder and click on Save New Page.
  22. In the Save New Page dialog, enter test as the Name and click on OK.
  23. Click on Approve followed by Switch To Live Site. Note that the text entered in the placeholder is saved in a new posting.

    Getting Started with the Development Environment Using Microsoft Content Management Server

We have now tested our custom MCMS web application project templates. Before moving on, it is a good idea to tidy up our test files and projects. We can delete our test posting, its template gallery item, and the two MCMS applications we have created: mcmstest and mcmssp2.

Summary

We have reviewed the basics of the new Visual Studio 2005 MCMS development environment, configured the 'CMS' Virtual Directory, and have created our own custom Visual Studio 2005 templates for MCMS. We are now ready to dive into MCMS development with ASP.NET 2.0!

[ 1.a | 1.b | 2 | 3 ]

If you have read this article you may be interested to view :

Enhancing Microsoft Content Management Server with ASP.NET 2.0 Use the powerful new features of ASP.NET 2.0 with your MCMS Websites
Published: August 2006
eBook Price: $22.99
Book Price: $37.99
See more
Select your format and quantity:

About the Author :


Lim Mei Ying

Lim Mei Ying is a Senior Consultant at Avanade, a global technology integrator specializing in the Microsoft platform. Mei Ying has extensive experience in designing, implementing and supporting enterprise web applications as well as setting up Microsoft Content Management Server (MCMS) systems across the enterprise. An active contributor to the Microsoft newsgroup community, she has spent many hours figuring out the dos and don'ts of MCMS technologies, and thrives on the challenge of finding new ways to solve MCMS-related problems. Mei Ying, who has earned the prestigious title of Microsoft's Most Valuable Professional award for Content Management Server. Mei Ying lives on the sunny island of Singapore and blogs at meiyinglim.blogspot.com

Spencer Harbar

Spencer, a MCSD for Microsoft .NET, MCSE and MVP for MCMS, has over twelve years commercial experience of architecture, design, development, deployment and operational support of Web based applications and hosting platforms for some of Europe's largest organisations.

Spencer maintains www.mcmsfaq.com - a MCMS resources portal, and is active in the public newsgroups. His experience of MCMS goes back to the days of NCompass Resolution and he has been involved in many enterprise implementations.

Currently working as an independent consultant, Spencer delivers enterprise content management and portal systems architecture, design, development and deployment solutions, application security best practices, threat modeling and the implementation of highly available Windows Server System based hosting platforms.

Product expertise includes MCMS, SharePoint Technologies, IIS, SQL Server, Commerce Server and BizTalk Server, Windows Security, PKI and High Availability.

Selected clients include Barclays Bank, Scottish Power plc, HBOS, Microsoft, The Royal Bank of Scotland, Scottish Enterprise, Centrica, Clifford Chance, The Automobile Association and BASF

Stefan Goßner

Stefan Goßner works for Microsoft as an Escalation Engineer in the Developer Support department. He provides customers with technical solutions to problems related to Microsoft Internet Server Products. Stefan has breadth and depth in all areas of MCMS.

His contributions to the newsgroup have helped many people to implement MCMS solutions in corporations around the globe to the point where it has been said that if you don't know Stefan, then you're probably new to MCMS.

Stefan maintains a huge MCMS 2002 FAQ on the Microsoft Website and provides MCMS tips and tricks on his personal blog: http://blogs.technet.com/stefan_gossner.

He lives in Munich, Germany.

Books From Packt

Microsoft Silverlight 4 Business Application Development: Beginner’s Guide
Microsoft Silverlight 4 Business Application Development: Beginner’s Guide

Microsoft Silverlight 4 Data and Services Cookbook
Microsoft Silverlight 4 Data and Services Cookbook

.NET Compact Framework 3.5 Data Driven Applications
.NET Compact Framework 3.5 Data Driven Applications

MediaWiki 1.1 Beginner's Guide
MediaWiki 1.1 Beginner's Guide

CMS Made Simple 1.6: Beginner's Guide
CMS Made Simple 1.6: Beginner's Guide

Joomla! 1.5: Beginner's Guide
Joomla! 1.5: Beginner's Guide

Django 1.1 Testing and Debugging
Django 1.1 Testing and Debugging

iReport 3.7
iReport 3.7

No votes yet

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5
2
Z
c
j
1
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software