Below is my Controller Class:
using Pay.Models;
using System.Web.Http;
using Pay.General;
namespace Pay.Controllers
{
[RoutePrefix("Account")]
public class AccountsController : ApiController
{
[Route("Login")]
[HttpPost]
public UserSession Login([FromBody]LoginUser loginUser)
{
if (loginUser.email != null && loginUser.password !=null && loginUser.token !=null) { }
byte[] mSessionID = new Session().getmSessionID();
return new UserSession
{
SessionID = mSessionID
};
}
}
}
The Model class LoginUser is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Pay.Models
{
public class LoginUser
{
public string email { get; set; }
public string password { get; set; }
public byte[] token { get; set; }
}
}
But When I call the Login function, the LoginUser object is set to null. Please advise on how to set JSON objects into Controller class.