public static void SetConfirmationReturnUrl(this HttpContextBase httpContext, string returnUrl) { var confirmationContext = new ConfirmationContext { ReturnUrl = returnUrl, }; string json = JsonConvert.SerializeObject(confirmationContext); string protectedJson = Convert.ToBase64String(MachineKey.Protect(Encoding.UTF8.GetBytes(json), "ConfirmationContext")); httpContext.Response.Cookies.Add(new HttpCookie("ConfirmationContext", protectedJson)); }