Monday, May 14, 2012

PHP form includes and dreamweaver templates

Being used to pure C#, OO programming, and MVC, I was somewhat perplexed by the structure of this PHP website based on Dreamweaver templates. However, quick to adapt I have fixed several PHP bugs and applied several enhancements to the client's website with minimal costs, taking only a couple of hours to fix issues that would have otherwise taken a couple of days.

Monday, April 09, 2012

The Market Hotel Website Launch

This week I have launched the Market Hotel Website, completed from concept in circa 4 weeks, the website is now promoting one of the best pubs that I have been to in Hampshire.

Wednesday, October 12, 2011

Why is my server dragging its feet?

Last week I had major issues with two business critical applications. Both applications experienced serious time-out issues and sometimes did not even load for our users.

Monitoring the server I could not see any issues. CPU was below 40% at all times with the occasional spikes, and memory was also not running out. There was a large allocation of memory to the SQL server instance, but with two large databases running that was expected.

So the investigation continued, checking the local disks for fragmentation. Fragmentation was at up to 70%, which seemed to be the issue.

Next check was SQL fragmentation, checking the indexes, most of which were up to 95% fragmented, which also could have contributed to the issue.

After performing a series of defragmentation on the local disk and SQL indexes, the server was still performing very slowly although it finally was at least usable.

Next check which I completely forgot about is to check perfmon for memory, CPU and disk queue length. Disk queue length was running at 100% constantly, which obviously was not right. From this I checked the SQL log files and discovered that these were written to the same disk so decided to change the location of the SQL logs to a separate disk.

This seemed to have resolved the issue, with the disk queue running at a much lower level.

But then I restarted an integration service between two 3rd party applications and immediately the disk queue length jumped up dramatically. So even though all of the points above were important in terms of server maintenance and best practices, it was a 3rd party integration service that seems to be causing the issues. is about to launch

After working for over 6 months on a new site it is finally all coming together and is about to launch in the next 2 weeks. is a voucher discount site and has been built using .NET 3.5 and Entity framework. Initially, the idea was to write the whole application in .NET 4.0 using MVC and Entity Framework, but due to large scale restrictions imposed by the hosting provider ( I ended up coding it in classic ASP.NET forms. not only has a user friendly front end design but also a fully functional backend admin interface allowing the client to add new products, audit sales and create new offers.

The site has also been build with a complete set of code documentation and multi tier separation for easy support, by anyone who knows how to write in C#.NET

Thursday, August 18, 2011

Sometimes even the simplest stuff catches you out

I was playing around with using web services in a classic ASP.NET form web application, so that I could easily use jquery ajax calls to modify data. All was working fine until I deployed onto my hosting provider's web space, where I got the following error:
System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/MethodName'
It turns out it's another web.config setting (which makes sense) where you have to specify the required protocols. Here is the code:

                <add name="HttpGet"/>
                <add name="HttpPost"/>

Friday, July 29, 2011

Using System.Web.Profile in MVC web app project

I wanted to use the System.Web.Profile class in my MVC project to store user information that is used to retrieve data. This information included user id and the current user settings. While finding plenty of examples of how to use the System.Web.Profile class, almost none of the examples mentioned that
Web Application Project (unlike Wet Site Project) doesn't support generating strongly typed ProfileCommon classes from settings in web.config
So without further ado, here is what I had to do - as detailed on the always extremely useful
Create a new MVC model class and make it inherit from ProfileBase:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.Security;
namespace YourNamespace
    public class AccountProfile : ProfileBase
        static public AccountProfile CurrentUser
            get { return (AccountProfile)
                         (ProfileBase.Create(Membership.GetUser().UserName)); }

        public string FullName
            get { return ((string)(base["FullName"])); }
            set { base["FullName"] = value; Save(); }

        // add additional properties here
Now I still had problems with the Membership.GetUser() method because even though I have authenticated the user, the membership was null. So all I needed to do is to pass the username into the CurrentUser method.

static public AccountProfile CurrentUser(string username)
            get { return (AccountProfile)
                         (ProfileBase.Create(username)); }

You may ask why membership was null even though I authenticated the user. This was because I am using FormsAuthentication to set the token (i.e.FormsAuthentication.SetAuthCookie()). Membership was not set at this point. It was merely used to Validate the user (i.e. Membership.ValidateUser()).

So, this article actually overcomes a combination of issues.