ISAPI_Rewrite : a complete disaster!

I have been aware for some time about URL Rewriting on Apache via a .htaccess file. But recently working with Umbraco I discovered that version 4 incorporated a rewriting library to enable its use in virtual directories and provide friendly URLs, http://www.urlrewriting.net/149/en/home.html.   Some further research showed quite a number of rewriting libraries for IIS using ISAPI or HTTPModules:-

http://www.helicontech.com/isapi_rewrite/
http://urlrewriter.codeplex.com/
http://iirf.codeplex.com/

and Brendan Kowitz makes some interesting points in a 2006 blog entries, here.

What was more surprising was that my Hosting company had already installed version 3 of Helicontech’s ISAPI_Rewrite onto the Windows shared hosting I use. Therefore, it seemed an easy option for me to use it, but it has been a complete disaster.

Of course, with my first attempts I got the rules wrong and the rewriting just failed without any way of seeing the logs or error reports, as the Host company are the only persons able to access them. Eventually, with careful reading of Helicontech’s documentation I learned that when a .htaccess is in the root of a site the library removes a /, see http://www.helicontech.com/isapi_rewrite/doc/troubleshooting.htm

So if your rules start with a '/' character, this should be removed in .htaccess file in the root folder of web site.

Once I sorted my rules problems I found that changes to the .htaccess where not being responded to. Sometimes I got 2 of 3 rule changes and then nothing in 24hr. Helicontech’s forum support informed me that the most likely reason was NTFS permissioning, and “List Folder Contents” was needed. I wrote myself  simple ASP.NET website to look at the users and permissions assigned to the directories and I could see that they were correct. Raising tickets with my Hosting company got helpful responses which resulted in the current rule being updated, but a few hours later I was back to the same situation of changes to .htaccess being ignored. It seems that file watching is done using an internal method, System.Web.FileChangesMonitor and and I found suggestions during my research that some changes do get missed. This method is different from the .Net System.IO.FileSystemChanges method.

Well after a week I’ve decided to give up with ISAPI extensions rewriting. Since ASP.NET has a HTTPModules feature and Managed Fusion has an interesting open source product, I’m going to try this and I’ll be sure to blog about it in the future.

WebsitePanel : How to get working on Windows 7

About a year ago the Hosting company I use announced it was moving from Plesk to DotNetPanel. As I didn’t like Plesk and a brief look at DNP showed it had Zip and UnZip options within the FileManager, I immediately ask to be converted. Since then I’ve continued to be pleased by this decision, but it was only recently that I discovered DNP has gone Open Source and become WebsitePanel.

Therefore, I couldn’t resist having a look at how it works and see whether I could install it on my laptop. What I wasn’t expecting was the Installer indicated Windows Server was required. I posted a question on the Forum and one reply said it did work on Windows 7 and the other suggested using the Windows Server 180 day trial.

Not knowing WebsitePanel installing on Windows Server was my only option. Using VirtualBox, I installed Windows Server 2008 R2 Standard. Installation was straightforward other than my first repowering of the  instance failed -that needed a reboot of the laptop itself to resolve. In my haste I couldn’t resolve the networking issue preventing me from accessing SQL Server Express on my laptop, so I installed another copy on the Server.  After disabling much of the restrictive security that was annoying me, I installed Websitepanel in standalone mode without any issues. The installer created three websites, the database WebsitePanel, three local user accounts and hosting space in C:\HostingSpaces. Browsing to the three sites in turn, Enterprise Server http://127.0.0.1:9002/ and  Server http://127.0.0.1:9003/  show status pages, and the Portal http://127.0.0.1:9001 shows a login prompt. The highest authority login is “serveradmin” and the password was set during the installation. And if you ever forget the “serveradmin” password it’s via the installer you can reset it. The installer also creates an “admin” account using the same password. I then spent some time using the “serveradmin” account, creating customers and hosting spaces – all seemed to be working fine.

Since the three websites seemed very straightforward and all files seemed to have the same date except  each site’s web.config, I concluded it was just these three files that were modified during the installation. The next task was to see if these websites would work in my Windows 7 laptop. So I zipped them up, transferred them to my laptop and created websites using IIS Manager in the normal way. During my review of the website files I found the database install sql in the Setup directory of the Enterprise Server. On closer inspection the very first line of the sql file was parameterised - USE [${install.database}], I edited it to USE [WebsitePanel], created the database with Management Studio and ran the sql without issue. I then ran up the three websites and held my breath as the sites appeared to take a long time to initialise – but they did. I now had WebsitePanel working but with an empty database. I could of course have migrated the database from the Windows Server install, but as I wanted to see whether I could install  on Windows 7 directly, I decided I would see how I could login when the database wasn’t created via the installer.

Looking at the dbo.Users table I could see just a single “serversadmin” account but with a blank password. I knew from my previous installation on Windows Server the password was created during the install and was encrypted, so what was I to do now. My first attempt was just to copy the password and this worked fine, but that wouldn’t help you as the idea is to avoid the Server installation step. I could publish a default password here in this blog, but that seemed to me to be irresponsible. Then I noticed “<add key="WebsitePanel.EncryptionEnabled" value="true" />” in the Enterprise Server’s web.config. Changing to false allowed me to enter a password of my choice into the password field of the serveradmin row in dbo.Users and successfully log in. WebsitePanel seems to me to be working fine, so I achieved my aim of having it work on Windows 7.

But what do you have to do if you wish to avoid the Server install step. Well, if you look at the downloadable files at http://sourceforge.net/projects/websitepanel/files/ you’ll see that the three server components are available for separate download. When you unpack them and look at the web.config files of the Enterprise and Server sites you’ll see they are parameterised, (a) connectionString="${installer.connectionstring}", (b) key="WebsitePanel.CryptoKey" value="${installer.cryptokey}", (c ) <password value="${installer.server.password}" />. Substituting actual strings specific to your installation avoids the need for the installer.

That gets you a local installation with an unencrypted password, which is fine for training purposes. I’m not suggesting this approach is desirable for production. But what would you do if you wanted encrypted passwords? Well, as this is now open source you can obtain the source code and look for a method called encrypt(). I found very easy to copy this method into a test harness and create an encrypted password that I could cut and paste into the database password field. Again it seems irresponsible to post the code here – but it’s easy. I must admit that I haven't been able to compile the source code – there seems to be 3rd party libraries missing, so I’ll have to leave that to another post.

Using Windows Live Writer : first impressions

I’ve been using Windows Live Mail for some time and find it a very useful application to integrate together a few email addresses, but still allowing me to see my mail via hotmail for those times I’m not at my PC.

Having now started using BlogEngine, I’d thought I’d try Windows Live Writer as the blog’s documentation had mentioned the MetaWeblog API.

Well, here it is. My first post using Live writer.  Seems very competent. And got that ever necessary spell checker.

But I have to admit, I have gone over to using OpenOffice as my main word processor as I cannot stand the Office 2007 Ribbon and I certainly don’t want to fork out for something I don’t like. So I looked first to see if there was a MetaWeblog API extension to OpenOffice. There’s Sun Weblog Publisher but it looks too old, and there are report that some have had issues with it, so perhaps I’ll give it a miss.

Meanwhile, I’ll stick to Writer and see how it goes.

BlogEngine.Net - an initial install

Do you do something before reading the instructions? I do, especially when trying a new piece of technology or software. This blog is no exception. I've been intending doing something about a blog, mainly to keep notes about software matters, and it might as well be a blog too, in the vain hope that someone else might be helped by my musings or ineptitue.

Well I've just spent the evening installing my first BlogEngine.Net blog, having found the Codeplex site a few days ago. I did have a brief look at the docs to get a gist of how it should be installed and to find out the technical requirements. For me it has to work on shared hosting, be .Net 3.5 or lower and work from a sub-directory (which means a virtual directory). Seeing that it could, it was worth going deeper as it was clearly impressive software. As this is my first (successful) attempt at getting it installed, I thought it would make a fitting start as my first blog post about my experiences...

Looking at Codeplex it was clear that a source snapshot would be best as some bugs had been fixed that looked good to have. I browsed the code and it looked copable with, so downloaded it to my laptop. I was please to see the sln icon was VS2010, but suprised when it opened using VS2010 express - I've got both on my laptop. That makes the source code of this blog accessible to millions (potentially) and just goes to show what can be acheived with the free express editions.

The solution opened perfectly and built without a murmour - a very good sign for a quality open source project. I ran it and the development server burst into life with an impressive out-of the box site. I had read enough to know about the admin/admin login, and initially runs using an XML database. I could login, create a user, enter a page and it looked robust. Wow!

Next was to try SQLServer - but how to create the database? That got me lost for a few moments around the documentation - yes, I had to look!. Does it have an installation wizard like Joomla or Umbraco? Well, no! Eventually I found a reference to sql files in a setup folder and it clicked they were in the project. I could find ....\setup\MSSQLSetup1.6.0.0.sql, but horror SQLServer is at v9 now - would I have problems? But no, the db installed like a dream. Followed the intructions about the replacing the correct web.config file and editing the connection string and run it up on my laptop's IIS7.5 (Win 7 Ultimate 64 bit). No problem, it ran without a hitch. It was pretty obvious I was starting again with a new db, so in with that admin/admin login and try it out. Perfect! I worked round the admin options and scoped out the blog's features - impressive! Only comment here is you need to look for various things - where is the Admin menu, where's that login prompt, etc. One needs to keep an open mind when using for the first time as their locations are suttle and blended into the design. Well, now it was time for evening meal and a glass of wine! After I'd try the shared host.

Now, a bit later, I was feeling more confident. Better try on a localhost IIS first using same local db. VS2010 Express's Copy to Web feature came to my rescue to move to c:\inetpub etc, but decided I would use the normal Zip and FTP when it came time to move to the shared host. Getting a localhost website running was no problem using IIS Manager, and neither was BlogEngine - just another new db! Good, let's try with the shared hosting..., tea break, first!

Zipping, copying and unpacking to a sub-dir on the server was straighfoward, and I even remembered to set the App_Data directory to read/write as per the docs. Db no problem, but my host provider is a bit odd here, but I managed it. Another edit of the web-config file this time done on the server. Now, let's fire it up and bang, a ASP error! This was to say that error messages were turned off and I needed <customErrors mode="Off"/> in the web.config file. Now with error messages on I tried again and pow, another error. This time the ASP, not a virtual directory one - silly me. Try again and now can't get to the db cos I miss-typed the database name. And again, but an error to say it can't access web.config - what, I just edited it! Oh, of course, I FTP'ed the files I need to change the read permissions on everything. Done and hurrah!, it works. Now, yet another new db so I'm in with admin/admin again.

Well this blog is far better than I've seen with Joomla. I'll think I'll keep it, hence writing this.

What are my first impressions writing this?

  • Firstly the editor's good. Better by far than the ones in Joomla and other web apps I've tried. Need to find out what component it is...
  • Second I don't like the fact there's only a save button that closes the editor - I want an apply button as well as a save/close - yes, I save as I go after many years of loosing what I've typed.
  • Thirdly, the apply and save buttons should be below the editor and not at bottom of page - on my widescreen laptop I need to keep scrolling down the page.
  • And fourthly, I need a spellchecker. Oh, I'll proof read this tomorrow!


Well, now it's bedtime. Tomorrow I need to learn by way though .htaccess files to redirect my domain name to this blog. RegEx expression, uh!

bye for now, thanks for reading, and I hope it's helped

John