protected void imgValidationImage_PreRender(object sender, EventArgs e) { Guid captchaToken; if (ViewState["captchaToken"] == null) { Allegiance.CommunitySecuritySystem.Server.ClientService cs = new Server.ClientService(); Allegiance.CommunitySecuritySystem.Server.Contracts.CaptchaResult captcha = cs.GetCaptcha(200, 100); ViewState["captchaToken"] = captcha.CaptchaToken; captchaToken = captcha.CaptchaToken; } else { captchaToken = (Guid)ViewState["captchaToken"]; } Image imgValidationImage = (Image)sender; imgValidationImage.ImageUrl = Page.ResolveUrl("~/CaptchaImageGenerator.aspx?width=200&height=50&token=" + Server.UrlEncode(captchaToken.ToString())); }