In this tutorial, we will learn to create our own custom template which can be used for creating web sites
Web Matrix Custom Templates
What is WebMatrix
It is a web development Tool introduced by Microsoft, which comes with in-build components listed below
a development web server
a web framework
SQL Server Compact, an embedded database
It is mainly used when Developing web applications very fast by using templates and customizing it, which makes it easier when you want to extend or customize the existing site rather than writing from the scratch.
This article is mainly to show how we can create a custom template for WebMatrix, which makes it easy to get started creating websites and dynamic web pages.
Install WebMatrix : This can be installed using Microsoft's Web Platform Installer, its is a free software and easy to install and configure web-related technologies.You can download it from http://go.microsoft.com/fwlink/?LinkID=205867
WebMatrix comes with a couple of pre-built templates . In this tutorial we will learn to create our own custom template which can be used for creating web sites.
Select the "Site From Template"
All the Templates are stored under the path "C:\Program Files (x86)\Microsoft WebMatrix\templates" . Where you will see a list of .zip files, a folder called "resources" and a TemplateFeed.xml file:
Each of .zip folder contains 3 items
· Folder that contains the template site folder structure and files
These .zip files are actually Web Application Packages, which is the format that Web Deploy works to install an application on IIS
Create a Template named as "OrganizationSite" using the "Empty Site" Template
The WebSite will be saved under " C:\Users\<User Name>\Documents\My Web Sites" which can also be copied to C:\ drive root.
Add the folders and files which are required for the site or use the existing files from the pre-build templates
Modify the XML files manifest.xml and parameters.xml or else simply copy the ones from the Empty Site template and modify them to reference your new site name:
The 2 XML files are under the path "C:\Users\<User Name>\Documents\IISExpress\config\Web Deploy\OrganizationSite"
<iisapp path="OrganizationSite" />
This manifest.xml is used to copy the contents of "OrganizationSite" and make it an application in IIS. But make sure to Include this file in the root directory of your distribution package so that the application can be installed by Web PI (Microsoft Web Platform Installer)
description="Full site path where you want to install your application
By default, the application is installed in a Web site that has the same name as the path element of the iisapp directive in the Manifest.xml file. You must add a parameter similar to this one into your Parameters.xml file. The parameterEntry must have a type of "ProviderPath" and a scope of "iisapp."
This parameter is used to ask the user to specify a Web site and application name
You can copy the Site from " C:\Users\<User Name>\Documents\My Web Sites\OrganizationSite" to C:\drive root
Create OrganizationSite.zip file using Winzip or WinRar ,but make sure that the XML files are placed in the root of the resulting zipped folder.
We need to generate an SHA-1 cryptographic hash value for the.zip file. This is used to verify the integrity of the file, and ensures that the contents have not been tampered with prior to creating an application on IIS. The easiest was to do this is with the File Checksum Integrity Verifier tool(fciv). If you don't already have it, download the utility from the link and put the resulting .exe in the root of your C:\ drive.
Open Command Prompt Start--> Run--> cmd and navigate to the C:\ drive. Now type the following
C:\>fciv C:\Users\<User Name>\OrganizationSite.zip -sha1
A mixture of numbers and letters are generated, which is needed for the next step.
Ex: This is the way we get when the above said command is run in command prompt
// File Checksum Integrity Verifier version 2.05.
ff610591b24906c971d0d899ae3ed39e672fb409 C:\users\<User Name>\OrganizationSite.zip
Add the entry of the created site in the TemplateFeed.xml which is stored under "C:\Program Files (x86)\Microsoft WebMatrix\templates"
<summary>Organization web site set up with jQuery and layout page.</summary>
<longSummary>Sample Organization Site with jQuery and Layout set up.</longSummary>
<link href="http://microsoft.com/web/webstack/OrganizationSite" />
Copy the .zip file to the templates folder "C:\Program Files (x86)\Microsoft WebMatrix\templates"
Now, when you choose the Site From Template option ,you will find OrganizationSite template:
In this way, we can create our own templates which can be used as a basis for developing the sites