I'm new to angular and while trying post a string to web api from angular project,the parameter in the web api Post method is always null.If i use [FromBody], the post method itself not getting called.If i remove the [FromBody] from the Post method .The method is getting called but the value of the parameter is null.Can anyone please help me here!!
SendTODB(db:Event)
{
this.http.post('https://localhost:44301/Student',this.inpuctstexts).subscribe((data)=>(<HTMLInputElement>db.target).value);
}
In My WebApi:
[ApiController]
[Route("[controller]")]
public class StudentController : ControllerBase
{
[HttpGet]
public ActionResult<List<Student>> StudentList()
{
List<Student> student = new List<Student>();
student.Add(new Student() { StudentName = "Mike", Marks = "200" });
student.Add(new Student() { StudentName = "Jack", Marks = "250" });
student.Add(new Student() { StudentName = "Jacob", Marks = "300" });
student.Add(new Student() { StudentName = "John", Marks = "500" });
return (student);
}
[HttpPost]
public ActionResult<string> student(string input)
{
return input;
}
}