How to make a Webapi based project return gzipped json.

If you do have access to change applicationHost.config, you can enable GZip compression for JSON responses by adding the appropriate mime type to httpCompression -> dynamicTypes

The ApplicationHost.config file exists in the following directory  C:\Windows\System32\inetsrv\config


<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">

<scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />

<dynamicTypes> ...

<!-- compress JSON responses from Web API -->

<add mimeType="application/json" enabled="true" /> ...


<staticTypes> ... </staticTypes>


How to get the value from a WinForms.Listbox not databound.

I was faced with a bit of a challenge this morning. In WebForms getting the value of the selected item in a ListBox is pretty straight forward. However what i found in WebForms as a different story.

To complicate the process I was adding items to the listbox using the items collections add method.

If you look at the Intellisence for LIstBox.Items.Add expects a single argument of Object. Typically this is just the Text that is going to be displayed. However adding an item where the Text shows one thing, but the value is a different thing requires a slightly different approach

Step1. Add a new Class to your project that has a Text and Value property.
private class ListItem
public string Text { get; set; }
public string Value { get; set; }
Step 2. When initializing the form, set the ListBox’s DisplayMember and ValueMember properties to your classes properties
listBox1.ValueMember = “Value”;
listBox1.DisplayMember = “Text”;
Step 3. Add your items e.g.
listBox1.Items.Add(new ListItem(){ Text = “some text”, Value = “some value”});
Step 4. Read the value on the item being selected.
in the Listbox’s SelectedIndexChanged event read the value by casting the Listbox’s selected item as your custom class and then reading the property you need.
e.g. ((ListItem)listBox1.Items[listBox1.SelectedIndex]).Value


Hopefully that helps..

Does IE Suck or is it every other browser..

Having been in IT for over 20 years I have definitely heard my fare share of Microsoft Bashing. Usually by people who have NO CLUE what they are talking about. Of course web designers – who know php and MySQL because it was free when they were in college – are probably the worst of the bunch.

What I have found is that no only do I see less issues with IE than other browsers, but it is actually faster. Every time apple updates their phones and browsers I cringe. This has caused hours of extra work due to their inability to follow standards. ON android browsers in tablets and phones, drop down menu’s don’t work (at the time of this writing) Even when the menu exposes a standard <a tag>

Anyway.. today I was looking at statistics gathered by google on our public website and was amazed at what the two fastest browsers were.

1. Edge (Microsoft 10) and
2. IE (stop the cheering or leering .. check out your site if you don’t believe a random test of 38,000 page views.)

What really blew me away was that Edge was nearly 50% faster than chrome (the next fastest non-Microsoft product) – I even prefer the debugging tools in IE10 (yeah 11 and edge suck – they are more like chrome – a giant step back)


“Fng Virus” removal tricks

So last night a buddy came over with a laptop that had developed a nasty cold that day (lunchtime)

The well designed little beast was quite liberal with his system – it had turned off emergency restore and would also grab hold of IE and cause it to do something that ate up CPU cycles and consumed HUGE amounts of RAM. This last bit of course was making it very difficult to do things like run anti virus software.

What I ended up dong was booting to safemode, and removing traces to the virus there.

I did find out that there is another cool options built into Windows today.
“System Configuration”

from the run command type “msConfig”
on the selective startup – deselect Load System Services and Load startup items, then in boot Choose Safeboot – with minimal selected.

Having the network adapter disabled would also be a good idea.

Go to the Services tab and check  “hide all Microsoft services” and press disable all (stopping services that should not be running from starting up) now reboot and remove the nasty bug – if you find a virus writer – tell some Muslim extremist group they insulted their prophet to ensure they have a slow and painful death!


As a note a friend I work with suggested the following utility

It is called combofix and is supposed to be good at fixing stuff that nothing else can get rid of, but it comes with a warning. It should be a last resort. It can render the OS useless and force you to do a reinstall of everything including the OS. However, it will also remove stuff that the others leave behind and give you back a system that would otherwise force you to reinstall anyway.


How to calculate religious holidays in SQL

I found this a few years ago, but like most things forgot where i found it. The whole thing is written to exist in a SQL database.

Holiday Calendar Calculator

It adds a table that references the holidays you want to generate and also a table valued function that takes a date range as it’s arguments. The output is all the holidays listed in the table by date and title.
For more usefull SQL (and other) scripts and help, visit

How to spot the differences.

Ok.. first of ..  SO what .

Reality – once you try this you will NEVER have an issue finding the differences between two similar pictures. As a test try finding the missing star in the bottom image without it.


It took me literally seconds to spot it after following the instructions on the above page


How to copy files from One Project to another during build – C#

A couple of key points.

  • There are a some special variables you can use to aid you.
    $(SolutionDir) and $(ProjectDir) These will always resolve to where the project is sitting and remove you need to have to script out the entire path.
  • Xcopy is the tool you need to do the copy, but at the end of the command you need to add the /Y parameter to ensure you don’t exit with “code 2″
  • The Place you need to add this to make sure the copy takes place is the “Build Events” tab of one of you solutions project directories


xcopy “$(SolutionDir)ControlProject\*.ascx” “$(ProjectDir)UserControls\” /Y

IN the above example, all ascx files are copied from a directory under the Solution (in my case a project that contains a number of UserControls) to the local project’s UserControls directory.

The /Y specifying that we will overwrite any existing files/

Validation of viewstate MAC failed. FIXED!

Have you ever experienced the good old “Validation of viewstate MAC failed.” Machine Key etc…

I had read a lot of different posts on various sites relating to this but just recently found a soulution. Most posts tend to hint at the Machine.config file (which you cant touch in a hosted environment) and or altering the Pages key of the web.config – which is most likely not going to work.

The trick is to actually add and encryption key to your web.config, it should be added to the system.web section.

The following link will create a machine key “Key” for you.

it should look something like..

<machineKey    validationKey="A7981C75ECB13C5626FBCD54CBC22786DD54480D5D37B3C9B19CE15CAE400F46E66F59BEF98BB82D3FBB4E4C500F697A1BFFBF43D184E240B589435DC66D3732"   decryptionKey="27186006621354C85C4154DB9F38410C8AA935322816E4C0E574EF0063DA3006"   validation="SHA1"   decryption="AES" />

Paste that into your web.config and say good bye to that annoying error!!


Rebuilding the UMBRACO Undex’s

There is an off chance that your index files in UMBRACO ( umbraco.config ) may become corrupt. If this is the case there is a nice built-in utilitie that can be used to rebuild all the index’s and fix the issues that your site is experiencing.

add the following to your website’s root address “Umbraco/dialogs/republish.aspx?xml=true”

e.g. if the site was you would enter

Follow the prompts.

I found myself having to use this to fix a problem where the Dynamic menus were adding nodes that didn’t exist and breaking links on nodes that did.

Quick and easy fix

Well done umbraco team.


Android codes

Android is going to be very popular now these days.Android market provides wide range of applications for fulfill all your needs.As a Android user all you need to know about Android OS. So here i m sharing with you some secret code. This code helps you to access some hidden option which are generally not given as default.Plz use this code carefully because if you are unaware of these advanced settings then it may be harmful for your phone.

*#*#7780#*#*   – This code is used for factory restore setting.This will remove google account setting and System and application data and settings.
*2767*3855#   -  This code is used for factory format, and will remove all files and settings including the internal memory storage. It will also reinstall the firmware.
*#*#4636#*#*   – This code show information about your phone and battery.
*#*#273283*255*663282*#*#*    – This code opens a File copy screen where you can backup your media files e.g. Images, Sound, Video and Voice memo.
*#*#197328640#*#*    -  This code can be used to enter into Service mode. You can run various tests and change settings in the service mode.
*#*#7594#*#*   -  This code enable your “End call / Power” button into direct poweroff button without asking for selecting any option(silent mode, aeroplane and poweroff).
*#*#8255#*#*  -  This code can be used to launch GTalk Service Monitor.
*#*#34971539#*#*    -  This code is used to get camera information.Plz avoid update camera firmware option.
WLAN, GPS and Bluetooth Test Codes:
*#*#232339#*#* OR *#*#526#*#* OR *#*#528#*#*   -  WLAN test (Use “Menu” button to start various tests).
*#*#232338#*#*    -  Shows WiFi MAC address.
*#*#1472365#*#*    -  GPS test.
*#*#1575#*#*    -  Another GPS test.
*#*#232331#*#*   -  Bluetooth test.
*#*#232337#*#    -  Shows Bluetooth device address.
Codes to launch various Factory Tests:
*#*#0842#*#*   – Device test (Vibration test and BackLight test)
*#*#0588#*#*    – Proximity sensor test
*#*#0*#*#*    -  LCD test
*#*#2664#*#*   -  Touch screen test
*#*#2663#*#*    -  Touch screen version
*#*#0283#*#*   -  Packet Loopback
*#*#0673#*#* OR *#*#0289#*#*    -  Melody test
*#*#3264#*#*    -  RAM version
Code for firmware version information.
 *#*#1111#*#*   -  FTA SW Version
*#*#2222#*#*   – FTA HW Version
*#*#44336#*#* – PDA, Phone, CSC, Build Time, Changelist number
*#*#4986*2650468#*#*   – PDA, Phone, H/W, RFCallDate
*#*#1234#*#*  – PDA and Phone