Website may be up and down over next few months. I'm currently doing a complete overhaul of everything. Going back to simple individual .htm pages, new overall site theme, sanitizing and cleaning up html of all pages and blog posts, attempting to implement a new tooling and publishing system etc etc.


The SilverlightExt extension for BlogEngine allows you to embed [ SILVERLIGHT xap:filenamewithoutext width:640px height:480px ] tags in your pages and posts so that you don't have to deal with writing html <object markup. All you have to do is upload your silverlight *.xap file into the ClientBin folder in the root of your site and type "[ SILVERLIGHT xap:filenamewithoutext width:640px height:480px ]" without spaces after [ and before ].


Source Code

using System;
using System.Linq;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;
[Extension("Embeds a silverlight object.", "1.0", "")]
public class SilverlightExt
    public SilverlightExt()
        Post.Serving += this.Serving;
        Page.Serving += this.Serving;
    private void Serving(object sender, ServingEventArgs e)
        var tagPattern = "
Get Microsoft Silverlight
, startPos + tagPattern.Length);
            if (startPos != -1 && endPos != -1 && endPos >= startPos)
                string argsString = e.Body.Substring(startPos + tagPattern.Length, endPos - (startPos + tagPattern.Length));
                string[] parts = argsString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    var xapFile = (from p in parts
                                   where p.ToLower().Trim().StartsWith("xap:")
                                   select new string(p.Substring(4).ToCharArray())).FirstOrDefault();
                    var width = (from p in parts
                                 where p.ToLower().Trim().StartsWith("width:")
                                 select int.Parse(p.Substring(6))).FirstOrDefault();
                    var height = (from p in parts
                                  where p.ToLower().Trim().StartsWith("height:")
                                  select int.Parse(p.Substring(7))).FirstOrDefault();
                     var htmlData = GetHTML(xapFile, width, height);
                    e.Body = e.Body.Remove(startPos, (endPos + 1) - startPos);
                    e.Body = e.Body.Insert(startPos, htmlData);
                catch (Exception)
    public string GetHTML(string xapFile, int pWidth, int pHeight)
        var data =
    "<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"{0}\" height=\"{1}\">" +
    "  <param name=\"source\" value=\"ClientBin/{2}.xap\"/>" +
    "  <param name=\"onError\" value=\"onSilverlightError\" />" +
    "  <param name=\"background\" value=\"white\" />" +
    "  <param name=\"minRuntimeVersion\" value=\"3.0.40624.0\" />" +
    "  <param name=\"autoUpgrade\" value=\"true\" />" +
    "  <a href=\"\" style=\"text-decoration:none\">" +
    "    <img src=\"\" alt=\"Get Microsoft Silverlight\" style=\"border-style:none\"/>" +
    "  </a>" +
    "</object> <iframe id=\"_sl_historyFrame\" style=\"visibility:hidden;height:0px;width:0px;border:0px\"></iframe>";
        data = string.Format(data, pWidth, pHeight, xapFile);
        return data;

Creative Commons License
This work by Dean Lunz is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License. Permissions beyond the scope of this license may be available at

Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume