Saturday, November 17, 2012

Deploying Custom User Controls for Sitefinity

If you ever have to deploy custom User Controls to Sitefinity that are written in Classic ASP.NET (not ASP.NET MVC), below are the following steps to accomplish this:

  1. After creating the project using Sitefinity Project Manager, open the project using Visual Studio 2010 or Visual Studio 2012
  2. By default the Visual Studio project will have a name of SitefinityWebApp
  3. After the project has been opened in Visual Studio, create a folder in the Visual Studio project to house the User Controls that you will be creating such as "UserControls"
  4. Add an ASP.NET User Control to the folder
  5. Begin developing the content that you want to add to the User Control
  6. Compile the SitefinityWebApp Visual Studio project using the Build option.  NOTE: If you use the Rebuild option, you will end up deleting unreferenced assemblies in the project thus causing additional problems with the deployment
  7. After compiling the project, you will have to register the control in the Toolboxes section in Advanced Settings
  8. After the control has been registered in the Toolboxes section, you should be able to open a Sitefinity Content Page and add the User Control as a Widget to the Page
  9. After publishing the Sitefinity page, you should be able to view the resultant page
  10. If you are then deploying this content to a hosted server for a fresh installation, you will have to do the following:
    1. Deploy the entire contents of the local directory structure
    2. If necessary, change the database connection string to provide the appropriate database credentials on the target hosting server
  11. If you are deploying changes to a hosted server, the steps you will have to follow differ slightly:
    1. Deploy any changes that were made to the local directory structure (such as the creation of the User Controls directory).  Any code behind files are not required, only the .ascx source code which contains the presentation code.
    2. Register the appropriate User Controls in the Toolboxes section of the Advanced Settings
    3. Deploy the SitefinityWebApp.dll to the bin directory on the target hosted server
    4. Add the widget to the appropriate Sitefinity Content Page and verify that the widget is working as expected

No comments:

Post a Comment