ASP.NET Login Authentication Problem

I was trying to create a Login page for my website in ASP.NET a couple of days ago and I was stumped that the following piece of code did not work:

private bool SiteLevelCustomAuthenticationMethod(string User, string Password)
{   
   bool boolReturnValue = false;
   DataTable dtAuthUsers = SomeBLL.GetUsers();
   if (dtAuthUsers != null && dtAuthUsers.Rows.Count > 0)
   {
       DataView dvAuthUsers = dtAuthUsers.DefaultView;
       foreach (DataRowView drvAuthUsers in dvAuthUsers)
       {
            if (User == drvAuthUsers.Row["User"].ToString() && Password == drvAuthUsers.Row["Password"].ToString())
            {
                boolReturnValue = true;
            }
        }
    }
    return boolReturnValue;
}

protected void LoginControl_Authenticate(object sender, AuthenticateEventArgs e)
{
    bool Authenticated = false;
    Authenticated = SiteLevelCustomAuthenticationMethod(LoginControl.UserName, LoginControl.Password);
    e.Authenticated = Authenticated;
    if (Authenticated == true)
    {
        FormsAuthentication.RedirectFromLoginPage(string.Format("{0}", LoginControl.UserName), false);
    }
} 

Now after numerous debug sessions on this code, I could not find a thing wrong with it. The correct Username and Password was getting parsed to the Database but still the 'SiteLevelCustomAuthenticationMethod' function was still returning a false.

What was causing this problem was actually quite simple (even though it had taken my a long time to solve!). Basically, in the User's table in my database had the following columns:

1) User_ID ------> DataType: int
2) Username ------> DataType: nvarchar
3) Password ------> DataType: char

Now this table look alright doesn't it? Well it isn't. The problem lies within the 'Password' column. Since this column format is 'char' with a length of 25, when you enter a password that is less than 25 characters in length a space will be added after to fill out the data length. For example, if you had a password that was 10 characters long, an extra 15 characters of spacing will be added after your password.

In order to fix this problem, I changed the Password DataType to 'nvarchar', which solved the problem. 

Broadband Speed Shock Horror!!!

A few weeks ago I was watching "The Gadget Show", which in the UK is a fun and informative show about gadgets (yeah the name of the show gave it away) and technology. Anyway, there was one episode which really got my attention. It was about the varied Broadband speed each household is getting around the UK. They believed that many people falling short of the "up to" speeds offered by their ISP, we're campaigning for the truth: advertised speeds reflecting what we're actually getting.

I decided to test their speculation out for myself by using one of these online "Broadband Speed Checker's". I used the following:

How Does It Work?

The speed checker downloads a file from the server and measures how long your connection takes to download it. The size of the file will be different according to your line speed. The speed checker measures the speed at the time of the test so if your network is running slow at that time then speed checker will report a slow speed. This does not necessarily mean that your internet connection is slow at the other times.

My Findings

I currently have a 2MB internet conneciton speed that is supplied by NTL (well now under Virgin Media). I carried out the test and not surprisingly my connection speed was not 2MB it was around 1.5MB. I know that compared to other users, my connection speed is not too much of a reduction. But still I am quite angry that I am not getting exactly what I paid for.

Well what are you waiting for? Give it a go and you might be surprised that you didn't get what you paid for! Leave a comment and share your results.

WOW! Windows Vista is...

...quite slow! This is what I thought as I was setting up my mothers laptop running on Windows Vista (compared to Windows XP Professional Edition running on a similar spec computer. I decided to run the "Windows Experiance Index" where Windows Vista determines the performance rate you are achieving. The score I achieved was a mere 3.3!!!

Anyway, how can I can I improve the general performance? Well I carried out the following:

1) Disable Indexing Service

The Indexing Service is a little program that uses a hell a lot of memory that indexes and updates lists of all the files that are on your computer. It does this so that when you do a search for something on your computer, it will search faster by scanning the index lists. If you don’t search your computer often, then why have something you don't need. To disable, cary out the following:

  • If you want, you can just remove any extra areas of search, so you can keep your fast searching for some areas.
  • Go to My Computer, right click on C: drive, go to the General tab, and uncheck Index this drive for faster searching, select Include subfolders and files. Select Add/Remove Programs.

2) Removing Sidebar

I have to say that the Sidebar looks great and displays information in the form of widgets really nicely! However, it can take some system resources and adds a longer startup time. This is dependent on the amount on info displayed on your Desktop.

3) Clear Up Restore Points

From the very first day you start to use your PC, Windows stores shadow copies of your system files. Over time, the amount of shadow copies can waste precious space. Windows Vista allows you to remove all restore points up to the most date. To do this carry out the following:

  • Goto Start, Accessories, and System Tools.
  • Click on Disk Cleanup.
  • When the Disk Cleanup window appears, click on the 'More Options' tab.
  • Under 'System Restore and Shadow Copies' section click 'Clean Up...'

Voila! You will see the amount of disk space that has been freed! Awesome!

4) Hibernation is a No No!

Yeah I have to admit the Hibernation feature is cool feature that allows you to startup your PC in the condition you left it. The only thing is that the amount of memory that it consumes is quite large. So its now a good idea to overuse this function.

Watch out for the Automatic hibernation process runs constantly in the background using up resources. If you’re happy to hibernate manually, and you’re not using a laptop on battery power, switch it off by the carrying out the following:

  • Open Control Panel.
  • Select System and Maintenance and click 'Change when the computer sleeps'.
  • Set 'Put the computer to sleep' to Never and click Save changes.

5) Tweak VI

This software provides a wealth of tools for messing with Vista's guts, including a boot-configuration manager, a CPU optimizer, browser-settings managers and tons more. Whats even better...its free!!!!

6) Disable User Account Control

User Account Control puts in a layer of security that stops you from making system changes without confirming them. More experienced users willing to take the security risk can disable this to speed things up when performing low-level tasks. User Account Control can slow down and can be irritating. To disable, carry out the following:

  • Open Control Panel.
  • Choose User Accounts and Family Safety.
  • Select User Accounts and click Turn User Account Control off.

7) General Updates

Ensure your PC is up-to-date with the most current patches. This will also help improve performance, but very slightly.

8) Disable Unused Startup Programs

Try and reduce the amount of programs that need to be run on startup. You will find the utility to disable any unwanted startup programs in Windows Defender. Yes, I thought that this was a strange place as well! But I have to say it is a good idea because the Software Explorer feature lets you take a close look at every running program and remove or disable those that are starting automatically.

Well give it a go and if you find any extra things to add here, please leave a comment!