.net framework c# web api,将用户名和密码作为字符串数组从邮递员发送到正文中

.net framework c# web api, send username and password as string array in body from postman

我尝试使用下面的代码从正文中读取 username/password,但我得到的只是 'object reference not set to an instance of an object' API的代码:

[Route("api/login_test")]
[HttpGet]
public object login_test([FromBody] string[] Username_Password])
{
    string UsernameOrEmail_address, Password;
    UsernameOrEmail_address = Username_Password[0];
    Password = Username_Password[1];

    return UsernameOrEmail_address  + " " + Password;
}

通过更改它工作的 Http 请求,从 HttpGet 替换为 HttpPost

[Route("api/login_test")]
[HttpPost]
public object login_test([FromBody] string[] Username_Password])
{
    string UsernameOrEmail_address, Password;
    UsernameOrEmail_address = Username_Password[0];
    Password = Username_Password[1];

    return UsernameOrEmail_address  + " " + Password;
}