传参的关键是JSON.Stringify,直接传递obj2是不管用的,axios接受json格式的数据
[HttpPost]
[EnableCors("CorsSample")]
public void Post([FromBody] string value)
{
}
let obj2="2323"
axios.defaults.headers.post['Content-Type'] = 'application/json';
axios.post('http://localhost:5000/api/EmployeeInfo',JSON.stringify(obj2))
axios({
headers: {
"Content-Type": "application/json;"
},
method: 'post',
url: 'http://localhost:5000/api/EmployeeInfo',
data: JSON.stringify(obj2)
})