Wednesday, 24 March 2010

Ektron and Web Application Projects (Part 2)

In Part 1, I discussed why you might want to develop your website outside of the default Ektron workarea and gave a brief overview of your options.

This time around, I’m going to show how to configure your Visual Studio Solution and projects and IIS to get you started.

You will need:

  1. A standard Ektron cms400min workarea website (I usually just call mine /Web – and copy directly from a fresh cms400min install!)
  2. A Web Application Project (clientproject.Website)
  3. A ‘3rd Party’ folder which will contain subfolders for the project dependencies binaries (this includes Ektron) and any helper utilities
  4. A ‘Virtual Directories’ folder (that isn’t included in the VS solution).  Move the uploadedFiles, uploadedImages, assets and privateAssets folders from the /web folder into here.  This will stop VS from rescanning the folder each time there’s a change.  If you don’t want to do this then you can set the hidden flag on just those folders (not their children) by right clicking and selecting properties.  I prefer the clean separation approach as the uploaded files and images are data and the asset files are generated artefacts.
  5. Optional: Class libraries containing business and helper classes (clientproject.Website.Support)
  6. All of the projects live in solution folder (imaginatively named clientproject) which also contains the solution file (also called clientproject) and a strong naming key.

The folder structure should look like this:

image

This may look complicated but it allows us to easily use source control (such as TFS or Subversion) to allow multiple developers to work on a solution and is Best Practise.

In keeping with the best practise handling of 3rd Party libraries:

  1. Move all of the files from ‘/Web/bin’ into ‘/3rd Party/Ektron’
  2. In Visual Studio, right click on the /Web website and select ‘Add References’
  3. In the dialog box, click' ‘Add’ and browse the /3rd Party/Ektron and select all of the dll’s
  4. Click Ok.

This will create ‘.refresh’ files in the ‘/Web/bin’ folder which can safely be checked in to any version control system.

Configuring IIS for the Workarea Website

The IIS configuration can be done now so we can begin to configure Ektron via the workarea.  This is a relatively simple procedure:

  1. Create a new Website (I prefer a format like local.cms.clientproject.dev.companydomain local as it’s a local developer version, cms as the workarea is present and the .dev.companydomain gives the opportunity to expose the environment externally via DNS).
    1. Associate the new website with the /web project.
    2. Set up the website Application Pool (I use IIS 7)
      1. Use the Integrated Pipeline
      2. Check that it’s running as the Network Service user
      3. Disable ‘pings’ (this will make debugging much easier!)
    3. Ensure that the web.config contains all of the handler mappings from the IIS 7 example configuration file (Usually found in C:\Program Files\Ektron\CMS400vXX\CommonFiles\IIS7Web.config)
  2. Create a ‘Virtual Directory’ (not an application) for each of the folders within /Virtual Directories names exactly as they would usually appear as folders in the workarea ie:
    • assets
    • PrivateAssets
    • uploadedImages
    • uploadedFiles

Validate the Workarea Website Modifications

The workarea website should pretty much be complete now from a infrastructure configuration point of view. but you will need to amend the following web.config settings:

  1. The Ektron.DbConnection database connection string
  2. The sessionState connection string – if your storing session in SQL Server
  3. The WSPath in appSettings should read ‘http://local.cms.clientproject.dev.companydomain/workarea/ServerControlWS.asmx’ (and you should be able to view that page as well)
  4. Any other settings (email servers, etc)

You should also be able to run SearchConfigUI (remember to right click ‘Run As Administrator’ in Windows Server 2008 or Windows 7).  Define meaning full catalogue names and check that the Assets and Private Assets directories have been correctly located (within the Virtual Directories folder).

You should now be able to log into the website by visiting ‘http://local.cms.clientproject.dev.companydomain/cmslogin.aspx’ and using the builtin account the was configured when Ektron was installed.

Setting the Solution the Build Order

It’s probably a good idea at this stage to configure any Code Analysis rules on the clientproject.Website and clientproject.Website.Support projects and to configure the dependencies and set the assemblies to be strongly named.  You should ensure that build order of the solution goes something like:

  1. clientproject.Website.Support
  2. clientproject.Website
  3. /Web

You can control this by setting project dependencies either implicitly by adding a reference to the clientproject.Website.Support project into the clientproject.Website project or by using the ‘Project Dependencies’ dialog (checking the build order in the ‘Build Order’ tab on the same screen).

Depending on the level on integration with the workarea you need, you can configure an IIS website to point at your Web Application project for lightweight testing of the your code.  Simply follow the instructions for configuring IIS but point the website at the /clientproject.Website folder.  This means you can quickly test your code, without IIS having to load all of the Ektron libraries.

At this point you can start to build your Ektron front end within the clientproject.Website and by copying some basic configuration from the /Web project (such as connectionStrings and appSettings). However, to deploy our web application into the Ektron workarea website we’re going to need some custom build steps, which I’ll cover in Part 3.

10 comments:

  1. using Ektron CMS400v70 and trying to move that to IIS7 environment...this version of Ektron does not have the C:\Program Files\Ektron\CMS400vXX\CommonFiles\IIS7Web.config

    Can you send me a basic IIS7Web.config? Any other tips you might have on IIS7 development of Ektron would be helpful.

    ReplyDelete
  2. Hi,

    I've uploaded the 7.6 version of the IIS7Web.config.

    http://bit.ly/arxPt0

    Hope it helps

    Martin

    ReplyDelete
  3. What a great post, it's very useful to me.
    Regards
    www.itsolusenz.com

    ReplyDelete
  4. Good afternoon! Thanks for having such a wonderful blog we are getting a ton out of what you are sharing.
    We currently have just one Ektron site. It’s been around for several year and Ektron upgrades. We've been using the default method of development and find it excruciatingly slow to compile, debug and generally work with, so I've been tasked with restructuring the project. I'm new to the company and Ektron and am having "fun" figuring all of this stuff out. I'm trying to follow your instructions above but need some help and clarification if you have a few minutes.
    We are on Ektron 8.01 SP2 (haven't upgraded to 8.02 yet, will probably wait for 8.5)
    I have your basic file structure created with a new website project created under SELInc.Website where SELInc is the name of our website, and a copy of Ektron under Web. Our current Ektron working directory is there as well under www.
    Note, I'm working on a branch in Subversion, so no worries there . . .
    I moved the solution file from SELInc.Website to up one dir as your image shows.
    Questions:
    I’ve also created a project for the Web directory (Ektron min) and included it in the solution, I assume this is correct? I’m converting it to a web app project but am not sure what I need to “Include in project”. I.e., the work area is huge, do I need to include this in the project? Etc.
    Do you have some more screenshots you’d be willing to share, perhaps of a solution explorer?
    I’m working through this, but some of it is still a bit confusing.
    Thanks!

    ReplyDelete
  5. Hi Dave,

    Don't convert the ektron minsite to a Web Application Project, it's way too much trouble and you'll need to repeat the exercise with each update.

    The idea behind this is to seperate your work from Ektron code in a Web Application Project and then using a After Build step, to copy the content (and compiled libraries) from the WAP into the minsite. This will all then run as a website project.

    ReplyDelete
  6. Also, check out Part 3 which details the post build event.

    ReplyDelete
  7. Martin, thanks for the extra info. I have it all setup and working as you suggest. My site files are being merged into the Ektron Web directory and the site compiles and works great. The next question I have is in regards to deployment. I'm used to using web config replacements in conjunction with web deployment, but they don't seem to work with plain web sites, only web applications. Do you have a deployment strategy and if so what do you do / use?

    ReplyDelete
  8. I generally use Web Deployment Projects or MSBuild scripts to handle the substitutions as part of my CI process.

    ReplyDelete
  9. Hi Martin.

    This sounds great.

    How does debugging work in the WAP without the workarea? Is there any issue developing widgets or other code that is dependant on ektron components?

    Thanks.
    Kevin.

    ReplyDelete
  10. Thanks Martin for the post. Where is Part 3?

    ReplyDelete

Got something to say? Let it out then!
Comments are moderated, so it may take a while to for them to be displayed here!