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.
- Open Visual Studio 2005.
- From the File menu, choose New, followed by Web Site…
- 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.
- 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.
- In the Language combo box (shown in the following figure), select Visual C#, and click on OK.
If you wish, you can also choose VB.NET. The samples in this article series are all written in Visual C#.
- 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.
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.
- Click on the MCMS Template Explorer tab at the bottom of the Solution Explorer, and note that the Template Gallery is accessible.
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.
- 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.
- 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.
- From the Start Menu click on Run, enter inetmgr in the Run textbox, and click on OK.
- In Internet Information Services, expand the tree view to display the mcmstest application.
- Right-click the mcmstest application and click on Properties.
- Click the ASP.NET tab and note that the ASP.NET version is correctly configured as 2.0.50727.
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.
- 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.
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.
- 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.
- Switch back to Visual Studio 2005.
- In Solution Explorer, right-click on the website (http://localhost/mcmstest), and click on New Folder.
- Enter Templates as the folder name.
- Right-click on the Templates folder and click on Add New Item…
- In the Add New Item dialog, select the MCMS Template File item and enter Basic.aspx in the Name textbox. Click on Add.
- The new Basic.aspx template file is created and opened in Source View.
- Examine the contents of 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.
- 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.
- From the Build menu, choose Build Web Site. Notice that the website now builds, but still includes a number of errors.
- Correct the DOCTYPE. On line 19, replace
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- Correct the <html> element. On line 20, replace <html> with <html >.
- Delete the comments on lines 4 through 17.
The comments within an inline ASP script block (<% %>) are unnecessary.
- 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#">
These <meta> tags are unnecessary.
- Correct the WebControls Register directive. On line 2, replace:
<%@ Register TagPrefix="cms" Namespace="Microsoft
<%@ Register Assembly="Microsoft.ContentManagement.WebControls,
Version=5.0.1200.0, Culture=neutral, PublicKeyToken=31bf385
The original Register directive is not correctly recognized by Visual Studio 2005, and prevents IntelliSense from including the cms tag prefix.
- 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.
- Your template file should now be as follows:
<%@ Page language="c#" AutoEventWireup="false" CodeFile="Basic.
<%@ Register Assembly="Microsoft.ContentManagement.WebControls,
Version=5.0.1200.0, Culture=neutral, PublicKeyToken=
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<form id="Form1" method="post" runat="server">