Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am developing web site in angular js, .net web api 2, visual studio 2013, and c#.

My url navigation is purely driven by angularjs.

Upon password reset, I email a link to the user that looks like this:

http://localhost:3458/api/Account/ResetPasswordEmail?userId=xxxxxxxxxxxxxxxx9049a8e3-fb90-400a-b73e-78cadc16ae40&code=BVEssssssssssssssssssswT9FsJ3QncMLaPclhLZVUHpHifX8wmG7f3ZrlxDlwkkmcMNccdXz8jdEuGdHM1FJ4WdBu9Yxu9VG43DxamBrasdfasdfasdfbdasdfvgGrqwJxRoJ%2FSCDkOrbV3RupmUaoTgRmebwb1ymBZwkd891G3q6SW%2F%2FTDwOQ7qrkzkAUYtjcwd%2FTH4jNNCzIYmMXF%2BkMF26mBM4Osgc%2Bi%2BO0So41%2Fpp3yK%2BDvEtNCPA%3D%3D&newPassword=xxxxxxxxxx

User receives the email and clicks on the link..

On the server side, following code is executed:

    //
    // GET: /Account/ResetPasswordEmail
    // GET api/Account/ResetPasswordEmail
    [Route("ResetPasswordEmail", Name = "ResetPasswordEmail")]
    [AllowAnonymous]
    public HttpResponseMessage GetResetPasswordEmail(string userId, string code, string newPassword)
    {
        string errmsg = string.Empty;

        try
        {
            if (userId == null || code == null)
            {
                errmsg = "Either email address or other necessary parameter is null.";
                throw new Exception(errmsg);
            }
            var result = UserManager.ResetPasswordAsync(userId, code, newPassword); 
            var response = Request.CreateResponse(HttpStatusCode.Moved);
            string fullyQualifiedUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority);
            response.Headers.Location = new Uri(fullyQualifiedUrl);
            return response;
        }
        catch(Exception ex)
        {
            return null;
        }
    }

The password is reset successfully... However ... I want to give visual feedback on the web page that password was or was not reset successfully. In other words, in this situation how would my web api talk back to the angular js code to render a UI. Would I resort to some sort of asp.net mvc type of code?

share|improve this question
    
You can rely on the status code, though "301 Moved" is kind of wierd IMO – Cory Silva Jan 16 '15 at 4:23
  • In your website project's controller folder need to add action which where user will land from email
  • Then call api from that action if success then return success view in that action
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.