I have been using BlogEngine.NET for some time now as my full web site and I have been especially happy with the arrangement. When I switched over to BE my previous experience told me to create separate .aspx pages for stand-alone content. I didn’t see the need to use the BlogEngine Pages feature, especially since I didn’t like that the url path includes …/page/pagename.aspx. What I found out when doing things this way was that I couldn’t use any of the theme and events that come along with the BE master page. So I reluctantly switched to using BlogEngine Pages instead of adding separate .aspx.
Even though I still don’t like the url syntax I am very happy with the results. After running this way for a while I figured out some things that I thought might help others to know as well.
So here is my list of things to know about using BlogEngine Pages:
Not all Extensions are loaded by default
Some of those really cool extension add-on’s aren’t configured to fire on Page.Serving so they don’t fire when you are viewing a page. This is a relatively fix if you know how to go into the extension and add the Page.Serving handle. Easiest way to see if the extension is working is to load a page and then view the source for the results of whatever the extension is supposed to do.
Tiny_MCE blows up your syntax
I really hate the built in tiny_mce editor. I’m sure it’s a fantastic product in itself but the default implementation on BE is very frustrating. For example, if you add an attribute name=”something” it will get stripped. If you try and add a <script> tag it will get stripped. The list goes on and on. If you are determined and scour the forums you can find hacks to change this behavior, but why? If you want to create pages that include script tags then you should be using Windows Live Writer. With WLW you can add pretty much anything you want to the page markup without any problems.
Embed UserControls into your pages
It took me a little while to figure this one out but you can easily add user controls to a page (and also a blog post) by using a simple syntax:
[ usercontrol: ~/User controls/MyUserControl.ascx option1=something;option2="something else";showDesc=true ]
Create UserControls for extended functionality
Writing your own code is a good thing. Adding it to pages using UserControls is an even better thing. Creating UserControls allows for drop-in functionality and makes it easier to add code into multiple places. You can even add optional parameters to the UserControl that can be passed during the load that customizes the call. For example, I load the same UserControl four times on my Toolbox Page so that I can separate each category of toolbox items. Trying to do this outside of a UserControl would be a nightmare.
Load JavaScript only when you need it
Using JavaScript (or jQuery if you want an easier life) on your blog is really useful. Instead of loading all your JavaScript into your site.master page why not add them only when necessary. By including the <script> tag at the top of your page you can achieve the necessary script load without having it load for every blog entry and page in your site. And don’t forget, using tiny_mce for creating pages will strip the <script> tags out so use WLW for creating and editing pages with imbedded script.
Careful with your edits
Assuming you followed my advice and didn’t use tiny_mce to create the page you are sitting happy with embedded script tags in your page. Don’t do anything crazy like try and edit that fully functional page with tiny_mce or you will experience the unpleasant fact that your embedded code has now been stripped out. I warned you. If you need to edit your page then use WLW again.
That’s all I can think of right now. Do you have any experiences with using BlogEngine Pages that you would care to share?




Kim Cameron's Identity Weblog
Sat, Nov 22, 2008
Technology