protected async void Page_Load(object sender, EventArgs e) { try { if (("log_out").Equals(Request.QueryString["mode"])) { if (HttpContext.Current.Application["AccessToken"] != null) { AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials()); GlobalSignOutRequest globalSignOutRequest = new GlobalSignOutRequest() { AccessToken = HttpContext.Current.Application["AccessToken"].ToString() }; await provider.GlobalSignOutAsync(globalSignOutRequest); HttpContext.Current.Application["AccessToken"] = null; Response.Redirect("Default.aspx"); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Token not detected');" + "window.location.href='Login.aspx';", true); } } } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ex", script, true); } }