0 Comments

Mads Kristensen created BlogEngine.Net back in 2007. I have tested Dasblog, Wordpress and imageBlogEngine.Net and decided back in 2010 that BlogEngine was my blogging platform of choice. But now in 2014 when responsive design, JSON, HTML5, CSS3 is all well known and supported. I decided to migrate to a new and minimalistic blog platform. It is called MiniBlog and hosted on GitHub. I really like the project’s name and goal. It has less overhead and is really fast! It is based on bootstrap, so responsive by default.

So the requirements for me for my new blogging platform is:

  • .Net C#
  • Bootstrap theme(s)
  • Lightweight
  • Fast
  • Live writer integration
  • RSS feeds (to feed to feedburner)
  • SEO friendly
  • Mobile friendly
  • Azure hosting support

Miniblog has it all. Because I am a lazy bastard programmer, I will call BlogEngine.Net BE and Miniblog MB. Here is how I moved from BE to MB:

1. Forked MB

So that I can contribute and give back to the community. And I can keep my own branch and have a local repository.

2. Moved App_Data posts

Copied all posts from BE to MB. But MB could not found my categories.

3. Formatted BE data for MB

Cloned this formatter to my desktop and uncommented line 17 and commented out line 18 of program.cs and renamed the folder parameter to origin in order to get it to run.

4. Made a custom theme

I have just copied one of the existing theme’s and made adjustments to the CSS (and razor view) You really have all freedom with this blogging platform

5. Moved login credentials

The default login is demo, demo and is stored in your web.config. You can change it, but perhaps accidentally commit it to GitHub, so follow this guide to move it to a separate authentication.config and exclude it in your gitignore.

6. Google Analytics

A plain installation of MiniBlog does not include Google Analytics “integration”. So you manually have to add the tracking code in your custom theme (from step 4) It is a good time to move your old Analytics to the new “universal analytics”. Add the snippet before your </head> tag.

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-XXXXXXX-X');
ga('send', 'pageview');

7. Syntax highlighter

To make the code snippets more readable I use this javascript library to enable syntax highlighting. At first, I took the wrong javascript files from the zip. I found the solution on this post about xregexp not defined.

8. Custom pages

MB is by default just a blogging platform and does not have custom pages for about and/or contact. It is better to add them in the view folder, but then you might have to do some work for better routing, so I added an about.cshtml and contact.cshtml to the root of the project. You can reference the theme’s shared layout there to make it match the rest of the sites layout.

9. Social sharing

This is also related to point 4. It gives visitors the option to share your posts on social networks which can give you a better reach. You can use AddThis or something similar. Or use the official plugins from Facebook and Twitter but that includes more javascript and dom manipulations which cause more load on server and client side. Which gives you less points with Google’s Pagespeed. So I combined the url’s from Hanselman’s post and the icons from Flaticon with the “embed resource as base64” option from web essentials Visual Studio extension.

10. Ads

I included a small javascript reference from developer media (previously lake quincy media) to add some ads to the posts (to try to earn back the money for my hosting bill) and included it in my theme, but I am still looking for the best performing ad dimensions.

11. Url-rewrite

I am using this free extension of IIS to rewrite some url’s and have added this rule to include the www subdomain:

<rule name="Add WWW prefix" stopProcessing="true">
  <match url="(.*)" ignoreCase="true" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^jphellemons\.nl$" />
  </conditions>
  <action type="Redirect" url="http://www.jphellemons.nl/{R:0}" redirectType="Permanent" />
</rule>
MB has default rules to remove the www subdomain (which I disabled) and has a rule to remove the .aspx which BE has, to get cleaner url’s


Have I missed something? What changes did you make when moving to MiniBlog?

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments
http://az83882.vo.msecnd.net/css/6.0.6002.18488.130611-1605/images/logo.png

This blog is online since April 2010 and has suffered from the Google Penguin update. The Blog has been on shared hosting since the beginning. But the shared hosting price plan is static and the Windows Azure price plan is based on how much you use it. So in my case, it will be cheaper to move to the cloud and azure also makes my blog more available.

This screenshot from Google Analytics once again proves that Google Penguin update did harm my blog’s traffic (24 April 2012)

google-penguin

Somehow my Blogengine.net 2.7 and also 2.8 installation on shared hosting keep getting errors which caused the IIS application pool to crash. It did not auto restart, so I had to bother the hosting company every two weeks to restart it manually. My installation keeps getting errors and I still need to look in for that, but Azure keeps working.


So I downloaded everything by ftp from the shared hosting and uploaded it on the azure hosting. When I hit my site by clicking on the url in the azure portal it failed to launch. So I’d reconnect with ftp and downloaded the errorlog.xml from azure.

I opened it in notepad++ which has XML syntax highlighting and it was the first event (when I clicked plugins –> xml tools –> pretty xml)

 

error CS0433: The type 'System.Web.WebPages.HelperPage' exists in both

So I opened the web.config of blogengine and went down to the assemblies and commented out the last three. Reuploaded the web.config and the BlogEngine installation runs fine!

webconfig-blogengine-azure

There was also an issue with the SMTP settings. So I googled for the smtp settings of gmail as smtp provider for blogengine and found out that the port 467 is not the correct one!

You need this XML for your web.config in order to get the smtp of gmail to work:

<system.net>
  <mailSettings>
    <smtp deliveryMethod="Network" from="capsoft@gmail.com">
      <network 
          host="smtp.google.com" 
          userName="yourGoogleId@gmail.com" 
          password="yourPassword" 
          port="25" 
          enableSsl="true" 
          defaultCredentials="false"/>
    </smtp>
  </mailSettings>
</system.net>

This page in the Blogengine discussion board pointed me in the right direction.

 

Good luck!

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

This is de default of BlogEngine 2.7:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <httpRuntime 
            enableVersionHeader="false" 
            useFullyQualifiedRedirectUrl="true" 
            maxRequestLength="16384" 
            executionTimeout="3600" 
            requestLengthDiskThreshold="16384" 
            requestValidationMode="2.0"/>
        <pages 
            enableSessionState="false" 
            enableViewStateMac="true" 
            enableEventValidation="true" 
            controlRenderingCompatibilityVersion="3.5" 
            clientIDMode="AutoID">
            ...
        </pages>
    </system.web>
</configuration>

And I have used these settings for quite a while. But my application pool keeps crashing after about a week.

I have enabled elmah logging

<elmah>
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/elmahErrors" />
</elmah>

This enabled me to have a better look at what was causing the crashes. Because the elmah page is of course unavailable when BE crashes. The log had several error’s the two most common ones where:

  • A potentially dangerous Request.Path value was detected from the client
  • Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
I have now added:
validateRequest="true"

to my pages section in the web.config and have added:

requestPathInvalidCharacters=""

to the httpRuntime section and my error logging feature stays empty and the BlogEngine application returns a nice 404 when trying some querystring injection and/or XSS attacks.

So this will fix all the thrown exceptions and keeps my application pool from automatically shutting down. I have found this on StackOverflow http://stackoverflow.com/a/6026291/169714 but turning off the validateRequest seems like a bad idea.


Good luck with BlogEngine!

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

My blog was offline a few days ago. The IIS application pool stopped. To investigate if it had something to do with my BlogEngine installation, I wanted to install Elmah. That was an easy one. Here is how I did it in just a few steps:

- download your current BlogEngine installation from the remote webserver

- Open it with Visual Studio (open website)

- Run it with Visual Studio to make sure that there are no build errors

- Right click on the solution:

image

- Select manage NuGet Packages

- Search for Elmah

- Hit install

- Edit the web.config, add

<authorization>
  <allow roles="Administrators"/>
  <deny users="*"/>
</authorization>
Just below
<location path="elmah.axd" inheritInChildApplications="false">
  <system.web>

And change

<elmah>
 <security allowRemoteAccess="false"/>
</elmah>

the allow remote access to true.

- Save and upload the new web.config, and upload and overwrite the files from the bin folder.

Only logged in administrators now have access to yourdomain.com/elmah.axd

Good luck!

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn
0 Comments

BlogEngine.net ping services

This is almost the default list of BlogEngine’s ping services with the UI you get after a clean install.

If you have no idea what a ping service is, you might want to think of it as directions your blogs shout to that there is a new post online. The more signals, the more traffic. So to increase that, you might want to extend the list more.

There are huge lists online available, but I am not going to insert them one by one by hand. So I fired up my FTP Client (Filezilla) and took the pingservices.xml and opened it in Notepad++

Pingservices.xml in notepad++

<service>http://link2pingservice.com/ping/RPC2</service>

the code is quite simple, so a batch add is easy to accomplish with a good text editing tool such as Notepad++. But why edit a raw XML file when you can also write some code to contribute to the BlogEngine open source community (and blog about it using Blogengine)[more]

So I created an account on CodePlex and downloaded VisualHG which is an extension for Visual Studio to use mercurial and TortoiseHG x64 which integrates great in explorer. I have used TortoiseSVN in the past a lot, so TortoiseHG is great for me.

The Tools –> Option window in Visual Studio did not gave me my VisualHG option. To enable that option, I needed to repair Visual Studio 2012 RC

Repair Visual Studio 2012 RC

I found that solution in this discussion on the Visual HG codeplex discussions board. It did took me a while to repair Visual Studio and required two reboots. But the option VisualHG as source control provider is now available.

missing source control plugin visual studio 2012 rc

The next step was to create my fork on Codeplex

create fork codeplex

The link is in the top right when you click on source control. After creating a fork, you can view the clone URL.

image

Create a new empty folder on your local drive to check out to.

clone tortoisehg

Then make changes to your source code and commit. The next step is to push the locally committed changes to Codeplex. I used the TortoiseHg Workbench for that:

TortoiseHg Workbench

After filling in your username and password, your code shows up online at your fork and you can click on the right on the option for a pull request, if you want your contribution to show up on the main branch. Of course this is only after the project administrator has reviewed the changes and addition of your source code.

Good luck coding!

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn