protected void SendToken_Click(object sender, EventArgs e)
        {
            ForgotParams forgot = new ForgotParams();

            forgot.Email = EmailID.Text;
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(WebConfigurationManager.AppSettings.Get("api-base-url"));
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                Task <HttpResponseMessage> task     = client.PostAsJsonAsync("forgotpassword", forgot);
                HttpResponseMessage        response = task.Result;
                if (response.IsSuccessStatusCode)
                {
                    Response.Redirect("~/ResetPassword.aspx");
                }
            }
            catch (FaultException ex)
            {
                ErrorLabel.Text = ex.Reason.ToString();
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = "Some unexpected error occurred :/" + ex.Message + ex.ToString();
            }
        }
예제 #2
0
        public string Post([FromBody] ForgotParams forgot)
        {
            string emailID = forgot.Email;

            try
            {
                using (UserProfileServiceReference.UserProfileManagementServiceClient client = new UserProfileServiceReference.UserProfileManagementServiceClient())
                {
                    client.SendPasswordResetToken(emailID);
                }
            }
            catch (FaultException ex)
            {
                throw new HttpResponseException(SetHttpErrorMsg(ex.Reason.ToString(), HttpStatusCode.BadRequest));
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(SetHttpErrorMsg("Some unexpected error occurred :/", HttpStatusCode.InternalServerError));
                //throw new HttpResponseException(SetHttpErrorMsg(ex.Message, HttpStatusCode.InternalServerError));
            }
            return("Token sent on email");
        }