I work as asp.net core application my issue I need to create web api on separate layer
and another layer will be for view
so how to make web page as view on another layer call this web api
are this possible
using Contracts;
using Microsoft.AspNetCore.Mvc;
using Services.Contracts;
using Shared.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TEAA.Presentation.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class FAQsController : ControllerBase
{
private ILoggerManager _logger;
private readonly IServiceManager _serviceManager;
public FAQsController(ILoggerManager logger, IServiceManager serviceManager)
{
_logger = logger;
_serviceManager = serviceManager;
}
public ActionResult GetFAQs()
{
var FAQs = _serviceManager.FAQService.GetFAQs( trackChanges: false);
return Ok(FAQs);
}
}
}
Jaimin ShethiyaPosted Apr 20, 2024, 8:56 AM
Hello,
Then you need to create another Web API application, and make the use of the HTTP Client and called the API.
Here is the article for calling the API.
https://www.c-sharpcorner.com/article/ihttpclientfactory-in-net-core/
https://www.c-sharpcorner.com/article/httpclient-use-polly-retry-policies-in-net-core/
Thanks
ahmed salahPosted Apr 20, 2024, 7:55 AM
I need to create asp.net core mvc layer on same project on separate layer
this web api will call web api for insert and update and deletje
so how to do that please
I don't need angular or react because i don't know these technologies
I need only create another layer on same project display web api by insert or update or delete or select
so can you show me that by details
Jaimin ShethiyaPosted Apr 15, 2024, 1:22 PM
Hello,
You need to create a seperate .Net Core Web API project, and for fron-end side you need to use Angular or React library.
Thanks
Bohdan StupakPosted Apr 15, 2024, 9:20 AM
It's hard to provide any code for the answer since it will depend on what technology you'll utilize for the view layer. But most commonly it is SPA framework and calling API controller there is as simple as making an HTTP call using fetch or a library such as axios.