I've a web api method like below `
[Route("api/[controller]")]
[ApiController]
public class TestController : ControllerBase
{
private readonly ISearchService _searchService;
public TestController(IRequestService searchService)
{
_searchService = searchService;
}
[HttpGet, Route("search")]
public List<ResponseViewModel> search([FromBody] SearchViewModel search)
{
return _searchService.GetSearchResults(search);
}
}`
SearchViewModel.cs
`public class SearchViewModel
{
public int ProductId { get; set; }
public int StatusId { get; set; }
public int ItemId { get; set; }
}
`
Question:
I wanted to send an object of type SearchViewModel class to the above Http Get action method from angular 12.
I can be able to achieve this with HttpPost by decorating search parameter with [FromBody] . But can someone please tell me how to do this with HttpGet .
Thanks in advance.