I have created Web.Api based on .Net-Core. There are two methods:
- IEnumerable GetRoles() - (Get)
- ResponseObject GetUsers(PagerRequest pagerRequest) - (Post). It has the following attributes: [Route("api/users/getusers")] [HttpPost]
Both methods are called by Angular. Method GetRoles is working find but problem is in POST.
PagerRequest is a simple class which has a few int properties. It's filled in by Angular. Fiddler shows correct JSON:
POST http://localhost/Pir.API/api/users/getusers HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 84
Accept: application/json, text/plain, */*
Origin: http://localhost:4200
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
content-type: application/json
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
{
"CountButtons": 5,
"ItemsCount": 0,
"PageSize": 5,
"CurrentPageIndex": 0
}
GetUsers method is calling but input parameter is not initialized. In another words desirialization is not working and I cannot understand why.
Before this project was based on classic .Net and run in the IIS. It was working fine. But .Net CORE is a problems.
Who knows where the problem is?
Below code examples:
-------------- PagerRequest.cs --------------------
public class PagerRequest
{
public int ItemsCount { get; set; }
public int PageSize { get; set; }
public int CurrentPageIndex { get; set; }
public int CountButtons { get; set; }
}
-------------- PagerRequest.ts --------------------
export class PagerRequest{
ItemsCount:number;
PageSize:number;
CurrentPageIndex:number;
CountButtons:number;
}