Make the Json.aspx authentication somewhat less broken.

Rolf, would you take a look at this to make sure I'm not breaking the universe? 

Thanks! :D
Andrew