How can I Map parameters to my Model in asp.net Web API? RRS feed

  • Question

  • I have this Api


    public IHttpActionResult Register(string Username, string Password, string Type, string Email, string Phone)

    User user = new User();
    user.Username = Username;
    user.Password = Password;
    user.Type = Type;
    user.Email = Email;
    user.Phone = Phone;

    return Ok(IUserRepo.Register(user));

    I tried using this
    public IHttpActionResult Register([FromUri] User) < - but it gives null in the User object this way.
          return Ok(IUserRepo.Register(User));

    • Moved by Fei Hu Tuesday, March 27, 2018 7:26 AM Asp.Net related
    Monday, March 26, 2018 1:58 PM

All replies

  • Hello zetwars,

    According to your question is more related to Asp.Net, you could repost a thread to Asp.Net forum for better support.

    If you have some grammar or code errors in using C#, please feel free to contact us. We will try our best to give you a solution.

    Best Regards,

    Neil Hu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 27, 2018 7:26 AM