0

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!

1
  • 1
    A view is for returning HTML. If you have a SPA app, those typically consume JSON, not HTML. So a view wouldn't be an appropriate thing to return. Commented May 14, 2020 at 15:30

1 Answer 1

1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.