I am getting below error, code is not able to find Controller and its methods. I am trying to add user to database from create user component.
Failed to load resource: the server responded with a status of 404 (Not Found)
Visual Studio 2019 Preview. Client - Target Framework : .Net Standard 2.1Server - Target Framework : .Net Core 3.1Shared - Target Framework : .Net Standard 2.1
dotnet --version3.1.200 ///Preview version
Controller Code
[Route("api/[controller]")][ApiController]public class UserInfoController : ControllerBase{ private readonly ApplicationDbContext dbContext; public UserInfoController(ApplicationDbContext dbContext) { this.dbContext = dbContext; } [HttpPost] public async Task<ActionResult<int>> Post(UserInfo user) { //some code here to add user to db }}
Component Code
private async Task AddUser() { Console.WriteLine("Add user method"); try { await userService.CreateUser(_user); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
User Service
public class UserServices : IUserInfo{ private readonly IHttpService httpService; private string url = "api/userinfo"; //Controller public UserServices(IHttpService httpService) { this.httpService = httpService; } public async Task CreateUser(UserInfo user) { var response = await httpService.Post(url, user); }}
Thanks for help.