MVC ajax post to controller action method

后端 未结 4 1690
慢半拍i
慢半拍i 2020-12-15 23:28

I\'ve been looking at the question here: MVC ajax json post to controller action method but unfortunately it doesn\'t seem to be helping me. Mine is pretty much the exact sa

4条回答
  •  一整个雨季
    2020-12-15 23:59

    It's due to you sending one object, and you're expecting two parameters.

    Try this and you'll see:

    public class UserDetails
    {
       public string username { get; set; }
       public string password { get; set; }
    }
    
    public JsonResult Login(UserDetails data)
    {
       string error = "";
       //the rest of your code
    }
    

提交回复
热议问题