Getting Started with the Development Environment Using Microsoft Content Management Server

0
93
7 min read

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 >.
  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 >

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

    <body>
    <form id="Form1" method="post" runat="server">
    </form>
    </body>
    </html>

Subscribe to the weekly Packt Hub newsletter

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here