简体   繁体   中英

How ReactJS interacts with ASP.NET MVC

Recently I've decided to try ReactJS for UI in my ASP.NET MVC application.

Everything looks more or less clear except the way how I should interact with controllers from/to JSX files and how should I pass data between them.

I've read different SO topics about this but found that almost everyone goes with some kind of unique way of doing that.

So, here is my questions : Should I make all my ASP.NET endpoints so that they return Json(model) instead of ASP.NET View() and use fetch/http-requests on ReactJS side to communicate with app?

Or is there a way to pass a model/data from a controller to JSX files from a view without changing controller actions behaviour (for example I want to leave «as is» my current return View(model) behaviour)?

Thank you!

Architecture really depends on your requirements, which are not specified here. I would recommend going with the separation of the front-end(ReactJS SPA) and back-end(ASP NET Core WebAPI) with communication via http protocol. If you have to stick to ASP Net MVC you can take a look on this library: https://reactjs.net/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM