P
P
Paul Fawkes2019-08-24 16:07:41
ASP.NET
Paul Fawkes, 2019-08-24 16:07:41

reactjs frontend in asp.net mvc??

How to display data from controller in reactjs using react routing??

public ActionResult Index()
    {
        var employees = _dataBase.Employees.GetAll();
        var employeesVM = new List<EmployeeViewModel>();

        foreach(var employee in employees)
        {
            var employeeVM = _employeeMapper.Map(employee);
            employeesVM.Add(employeeVM);
        }

        return Json(employeesVM, JsonRequestBehavior.AllowGet);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Egorov, 2019-08-24
@SergeyEgorov

And what does react routing have to do with it? You need to get JSON from your ASP.NET MVC controller using some http client https://github.com/axios/axios and render them in a view of some of your React component.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question