You get a hangover because ethanol inhibits your ADH (anti-diuretic hormone), which causes you to pee lots.
Because you're losing lots of dilute urine, you end up with a higher sodium concentration in your blood.
This high sodium concentration causes water to leave cells by osmosis.
As the cells become dehydrated (including your brain cells), they shrink, you then wake up with a parched mouth and a massive headache.
As you can see, the cure is lots of water!
In general, try to match your alcoholic drinks with non-alcoholic ones at 1:1 ratio.
If you can't do this then try to drink a pint or two of water before you sleep.
Happy not-getting-hangovers-ever-again day!