Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MC 19 posts 89 karma points
    Feb 27, 2014 @ 22:48
    MC
    0

    How to sent successful message after reset password link sent to email.

    Hello everyone,

        I have been working on the forgottenPassword almost 8 hours now but still no find solution to sent successful message after email sent the reset password link to customer email. I am trying to sent the message to display after email sent and redirect. I used Viewbag , TempData, Session , but no luck the value is always null, here is my code

     

    1.                  [HttpPost]
    2. [ValidateAntiForgeryToken]
    3.         public ActionResult HandleForgottenPassword(ForgottenPasswordViewModel model)
    4. {
    5.            if (!ModelState.IsValid)
    6.              {
    7.                    
    8.                 ModelState.AddModelError("ForgottenPasswordForm.", "No member found");
    9.                 return PartialView("ForgottenPassword", model);
    10.              }
    11.           else
    12.            {
    13.                
    14.                   EmailHelper email = new EmailHelper();
    15.                 email.SendResetPasswordEmail(findMember.Email,      
    16.                 expiryTime.ToString("ddMMyyyyHHmmssFFFF"));
    17.                TempData["Success"] = " A link to reset your password has been sent. Please Check your                      email."   
    18.                 return RedirectToCurrentUmbracoPage();
    1.            }

    /////////      Here is my view 
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @if (Request.HttpMethod == "POST")
    {
      @Html.Partial("_ForgottenPassword", this.GetModel<ARS.ViewModels.ForgottenPasswordViewModel>())
    }
    else
    {
       
         @Html.Action("RenderForgottenPassword", "AuthSurface")
    }
    Thank you in advance
  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Mar 02, 2014 @ 18:05
    Marc Goodson
    100

    Hey MC

    There are a couple of different ways of returning an action result from inside a surface controller to take the user to an Umbraco Page.

    They are

    return CurrentUmbracoPage()  this will display the current umbraco page with the modelstate in-tact, so if there is an error in ModelState, and you want to present the form again without wiping the rest of the form entries use that.(ie instead of where you return the PartialView on line 9 )

    You can also redirect to a specific thank you page you've created in the cms, perhaps a child of the node the form is on, hidden from navigation ie

    RedirectToUmbracoPage(nodeId) to take the user to a specific page by node Id

    or as you are attempting above to redirect to the current page, clearing out the ModelState values using:

    RedirectToCurrentUmbracoPage() 

    You should be able to add a message to TempData by using

    TempData.Add("Success", "your form was successfully submitted");

    and then display that message using

    @TempData["Success"] in the template of the current page or page that your redirect to...

    I can't see in the posted code above where you are writing out the TempData...??

    More info here:

    http://our.umbraco.org/documentation/Reference/Mvc/forms

     

  • MC 19 posts 89 karma points
    Mar 04, 2014 @ 22:00
    MC
    0

    Hi Marc  

    Thank you for your time to explain to me , I am very appreciate your help its very helpful .

    MC

     

Please Sign in or register to post replies

Write your reply to:

Draft