Web-MA ASP.Net MWPSK Seo Extension

Current Version: 1.0.2 relesead on 02/28/2008

An extension to let Microsoft My Web Page Starter Kit manage the meta tags useful for SEO Optimization

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The GNU license to which this software is referering is available at: http://www.gnu.org/licenses/gpl.txt

If you want, you can add a link to www.web-ma.com, making it easy for others to recognize the author of this script.

Why this extension?

Finding an open source CMS (hence free) written in C # 2.0, which does not need a database to store data is not easy. On ASP.Net platform, there aren't so much solutions like per Linux platform, and Microsoft guy did a great job when they released the MWPSK.
But like for everything, also in this case something was missing, at least looking into this CMS the personalization of the Meta Tag Description and Keywords is strictly at global level. And everybody in the SEO area knows how important are these meta tag. To be honest, the most important is the Description tag, while the Keywords today is on the edge.
The only local tag, important like the Description, that is possible to change locally is the page Title.
So, whit a bit of code, here is the solution, obviously based on the work MWPSK team did and stored on CodePlex.

Why use this extension?

Well you aren't obliged to use this; furthermore you don't need at all, expecially if you (or your customer) don't need your web page optimized also for the search engine.
But nowadays be listed between the first two-three pages of a SERP is fundamental, and since the major search engines don't like duplicated Title and description (and someone also keywords), I think this bunch of code may be usefull to everybody.

How to use this extension?

To implement this code, you need a bit of knowledge of ASP.Net programming. Despite code has been written and tested, you have to apply the changes below that has been written for the version 1.1.4 of the My Web Page Starter Kit.
A the end of the page, I will provide a zip file with all the changes described here, but since the base code may changes without notice, it would be possible in a (near) future that the zip file won't be valid.

Probably now you are asking why, since the My Web Page Starter Kit supports the section, I didn't implemented a simple section that is easier to install. The answer is easy. Due to the fact that a section can be added into a page more than once, adding more SEO Extetion section would have caused problem.
A part from this (because with some checks it was possible to make that section applicable just one time) if you think better on the scenario, the changes to the description and keywords meta tag, as well as on the Title, happen so rarely that their setting is right placed in the pages creation area, instead in the content area.
Another great reason, at least on my side, is that since the CMS is generally used by final customer, less changes a customer can do and better is.
In my case, since generally I follow customer also for SEO optimization, I wouldn't customers to do undesired changes on that small aspect of the page that would compromise the indexing of the page in the search engine.

Let's start now! Open your local project in Visual Studio.

  1. Firt of all we have to change the "page" structure, so edit the file in the App_Code/WebPage.cs and apply the following changes.
    Look into WebPage class, search the Title property, and immediately below add this code:

    /// <summary>
    /// The meta tag description of the page.
    /// </summary>
    public string Description
        get { return _data.Description; }
        set { _data.Description = value; }
    } /// <summary>
    /// The meta tag description of the page.
    /// </summary>
    public string Keywords
        get { return _data.Keywords; }
        set { _data.Keywords = value; }

    Now change the WebPageData class adding the respectively property used above in this way. Inside the constructor add the following declaration:

    Description = string.Empty;
    Keywords = string.Empty;

    then add two public properties:

    public string Description;
    public string Keywords;

    Add this static function to generate a Meta Tag. We will use this later in the Default.aspx.cs file.

    public static HtmlMeta generateMeta(string name, string content)
        HtmlMeta meta = new HtmlMeta();
        meta.Name = name;
        meta.Content = content;
        return meta;

    Finally add the following reference in the top of the file:

    using System.Web.UI.HtmlControls;

  2. Change the ~/Administration/Navigation.aspx code.
    Look for the Textbox that will manage the Title of the page, and add the code below:

        <td class="fieldlabel">
              <asp:Localize runat="server" Text="<%$ Resources:stringsRes, adm_Navigation_Description%>" />
         <td class="field">
            <asp:TextBox runat="server" ID="txtDescription" />
         <td class="fieldlabel">
            <asp:Localize runat="server" Text="<%$ Resources:stringsRes, adm_Navigation_Keywords%>" />
         <td class="field">
            <asp:TextBox runat="server" ID="txtKeywords" />

  3. Change the ~/Administration/Navigation.aspx.cs code.
    Look for showPageDetails method and add this code below the txtTitle.Text = page.Title; declaration:

    txtDescription.Text = page.Description;
    txtKeywords.Text = page.Keywords;

    Now look for btnSave_Click method and look for page.Title = txtTitle.Text.Trim(); code, then add the code below:

    page.Description = txtDescription.Text.Trim();
    page.Keywords = txtKeywords.Text.Trim();

  4. Change the Default.aspx.cs code in the root of the MWPSK folder.
    At the end of the Page_Init method add this code:

    if (_page.Description.Trim() != string.Empty)
        Header.Controls.Add(WebPage.generateMeta("description", _page.Description));
    else if (_website.Description.Trim() != string.Empty)
        Header.Controls.Add(WebPage.generateMeta("description", _website.WebSiteTitle));

    if (_page.Keywords.Trim() != string.Empty)
        Header.Controls.Add(WebPage.generateMeta("keywords", _page.Keywords));
    else if (_website.Keywords.Trim() != string.Empty)
        Header.Controls.Add(WebPage.generateMeta("keywords", _website.Keywords));   

  5. Finally the last change. You have to edit the StringRes.resx file (and repeat for all files you want to use for local language translation) and add these two following definition, used by the Navigation.aspx page.

    <data name="adm_Navigation_Description" xml:space="preserve">
        <value>Meta Tag Description</value>
        <comment>SEO Extension by Web-MA</comment>
    <data name="adm_Navigation_Keywords" xml:space="preserve">
        <value>Meta Tag Keywords</value>
        <comment>SEO Extension by Web-MA</comment>

  6. You have finished! Saves all the changes made and run your code. Starting from now you are able to change Meta tag description and kewyword for every single page.


For your best convenience I've provided a zip file with the MWPSK Seo Extension changes made on the original 1.1.4 version. You can use it without problem, but don't forget to backup your original file, in case you want to revert back or if you did changes that aren't in the version available in CodePlex code.

Back to Open Source Utility list or take a look at the Embed Resource section or Static Content section.


1.0.0 - First release;
1.0.1 - A little code improvement because I used some function written for this project also in my other extension, so if you don't use them, you can ignore this.
1.0.2 - This is just because I forget to write in the instruction above the using statenent for System.Web.UI.HtmlControls.


The extension has been integrated in the new version of the CMS. So, starting from release 1.2.1 you don't need anymore to download the SEO Extension.

Copyright © 2008 http://www.web-ma.com. All rights reserved.