I have two isolated applications one as a Web API using .Net core 3.1 and another one for Client-side using React and the two apps contact each other by HTTP requests now the challenge is I wanna integrate both of them as MVC so what is the recommended steps to do the integration.
1 Answer
If you'd like to migrate your existing WebAPI backend and React frontend apps to ASP.NET Core MVC, you may need to implement these functionalities from scratch in your new ASP.NET Core MVC project.
You can check each React component and the data passed/handled in that component, then create corresponding controller action and view page to implement same in MVC.
Note: normally WebAPI backend response and return data to React frontend, then we handle data on frontend and render it to expected html. In MVC, controller action usually return view result and pass view model data to view for rendering the web page.
For more information about "Passing data to views", please check this doc:
Besides, partial view and view component in ASP.NET Core enables us to implement a reusable and modular unit, we can implement reusable rendering logic as partial view or view component, then invoke it in other view.
For details about partial view and view component, please check these docs:
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-5.0
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-components?view=aspnetcore-5.0
4 Comments
React.AspNet etc that mentioned in above blog you shared would help achieve the requirement.