0

I have this action in my web api controller and using to return departmentId.

public IHttpActionResult GetDepId()
        {
            var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
            string name = User.Identity.Name;

            var depId = manager.Users.Where(d => d.Email == name).Select(c => c.DepartmentId).FirstOrDefault();
            return Ok(depId);
        }

But how to get this singel ID in Jquery ...? I'am trying like this but I get error "undefined"

function GetDept() {


            $.ajax({
                url: '/Api/userdp', // userdp is my controller
                type: 'GET',


                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (result) {
                    result; // failed even this result.Email; 
                },
                error:  {


                }
            });
        }

Thank you in advance!

Jonas Willander
  • 432
  • 3
  • 9
  • 29
  • Is the data your are getting back really a json ? – Ani Apr 30 '17 at 02:54
  • @Ani Thank you for your response. Now I'am confused..I'am trying to return departmentId from AspNetUsers and I realy dont know how to do. Could you please help me? – Jonas Willander Apr 30 '17 at 08:52
  • Here's a good example of what might be happening. http://stackoverflow.com/questions/10795516/function-returns-ajax-response-value-is-undefined-jquery-ajax – Ani Apr 30 '17 at 16:18

0 Answers0