Web Matrix - Custom Templates

Sunitha
Posted by in ASP.NET category on for Beginner level | Points: 250 | Views : 13748 red flag

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


·         IIS Express,  a development web server

·         ASP.net,  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.
  

Objective:

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.

 

Prerequisites:

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.

 

Step 1:

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

·         manifest.xml

·         parameters.xml

 

These .zip files are actually Web Application Packages, which is the format that Web Deploy works to install an application on IIS

 

Step 2:

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.

Step 3:

Add the folders and files which are required for the site or use the existing files from the pre-build templates

 

 

Step 4:

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"

<!--manifest.xml-->

<MSDeploy.iisApp>

<iisapp path="OrganizationSite" />

</MSDeploy.iisApp>

 

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)

 

<!--parameters.xml-->

<parameters>

          <parameter

               name="Parameter 1"

       description="Full site path where you want to install  your application

                          (ex: OrganizationSite/Application)."                 

       defaultValue="OrganizationSite"

               tags="IisApp">

         <parameterEntry

              kind="ProviderPath"

              scope="iisApp"

              match="OrganizationSite" />

          </parameter>

</parameters>


 

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


Step 5:

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.

 

Step 6:

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

 

Step 7:

Add the entry of the created site in the TemplateFeed.xml which is stored under "C:\Program Files (x86)\Microsoft WebMatrix\templates"

 

<entry type="application">

    <productId>OrganizationSite</productId>

    <title>OrganizationSite</title>

    <version>1.0</version>

    <summary>Organization web site set up with jQuery and layout page.</summary>

    <id>http://www.microsoft.com/web/webstack/OrganizationSite</id>

    <updated>2010-3-24T18:30:02Z</updated>

    <published>2011-09-08T11:00:02Z</published>

    <longSummary>Sample Organization Site with jQuery and Layout set up.</longSummary>

    <link href="http://microsoft.com/web/webstack/OrganizationSite" />

    <images>

      <icon>http://go.microsoft.com/fwlink/?LinkId=195176</icon>

    </images>

    <keywords>

      <keywordId>Templates</keywordId>

    </keywords>

    <author>

      <name>Microsoft</name>

      <uri>http://www.microsoft.com/</uri>

    </author>

    <installers>

      <installer>

        <id>1</id>

        <languageId>en</languageId>

        <installerFile>

          <fileSize>50</fileSize>

          <installerURL>  
                     file://%ProgramFiles%\MicrosoftWebMatrix\templates\OrganizationSite.zip
         </installerURL>

<sha1>f9e8146192325b1a30f35aadc760c504aa5141db</sha1>

        </installerFile>

        <msDeploy />

      </installer>

    </installers>

  </entry>


Step 8:

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:

 

 

 

Conclusion:

In this way, we can create our own templates which can be used as a basis for developing the sites

 

Page copy protected against web site content infringement by Copyscape

About the Author

Sunitha
Full Name: Sunitha Pothakanuri
Member Level: Starter
Member Status: Member
Member Since: 9/7/2011 1:28:21 AM
Country: India

http://www.dotnetfunda.com

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)