Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 3651 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > Web Matrix - Custom Templates

Web Matrix - Custom Templates

Article posted by Sunitha on 9/8/2011 | Views: 6241 | Category: ASP.NET | Level: Beginner | Points: 250 red flag

Advertisements

Advertisements
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

 

Advertisements

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Latest Articles from Sunitha
Experience:4 year(s)
Home page:http://www.dotnetfunda.com
Member since:Wednesday, September 07, 2011
Level:Starter
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points
Related Posts

After learning this tutorial, you will be able to generate a random password and send it to the user's requested mail address.

I will show you how to implement Password Recovery control with CAPTCHA included and how to handle the background processing.

In this tutorials, I am going to explain how to read appSettings and connectionStrings values from the web.config file.

There are many way of doing audit trail and in one of my previous article I had discussed how we can implement audit trail using prototype pattern

In this Article you can Know how to get a Multiple selected values using CheckBox

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 1:12:24 PM