As I studied articles and content on the web about creating a REST API using the asp.net core, I found out that shaving web pages are not usually used for interfaces. Most of them are focused on Angular 1 && 2 for processing api data coming from the server (Ex: $ http.get, $ http.post). I'm just wondering if there is any article that describes how to use clean razor web pages as an interface for working with web api, or are there any ways to do this correctly using the .net kernel?
For ex:
[Route("api/students")] public class StudentsController : Controller { private IStudentRepository _repository; public StudentsController(IStudentRepository repository) { _repository = repository; } [HttpGet("")] public IActionResult Get() { var results = _repository.GetAllStudents(); return Ok(Mapper.Map<IEnumerable<StudentViewModel>>(results)); }
And instead of using the Angular $ http service for rendering,
$http.get("/api/students") .then(function (response) { ... }
Is there any method for rendering api in razor mode?
source share