Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use ReactJS with ASP.NET CORE MVC?

I have worked in ASP.NET CORE MVC, before.

  • What are all the advantages in using ReactJS over ASP.NET CORE?
  • Would not that additional library & its components, slow down the page load, comparing plain Razor Views?

I tried web search, I am unable to get proper answers.

like image 942
Manoj Kumar Avatar asked Jan 10 '19 11:01

Manoj Kumar


2 Answers

If you have independent apps in PC,Phones tablet,etc,you could just use React and core web api which is front-end and back-end separation.

By using Angular/React with api in server side:

1.You eliminate process of generating HTML in server side and you save CPU.

2.API produces small payload (json) and Razor (html) would be much larger in size, constant full page reloads and postback round trip. so API and SPA save bandwidth.

3.API and SPA could have different versioning, scaling and deployment scenarios.

4.By using API you can support mobile app too and if you start by Razor you may need api in future.

Below are some opinions on using Angular/React or razor:

1.Razor supports mobile,and both are optimized and fast in their own way. Razor optimizes code by not using a tree like MVC does. React is client side so it doesn't really use a tree, but also optimizes data in the HTML to an extent.

2.Angular (or React) is far superior in terms of performance.The model-binding aspects of Angular is a gigantic advantage of server-side rendering. Using Razor(or server side rendering in general) does, however, lend itself to better overall integrity as far as data goes and it makes for a better transition of data from front-end to back-end.

See ASP.NET Core 2.0 Razor vs Angular/React/etc

like image 68
Ryan Avatar answered Oct 09 '22 03:10

Ryan


What are all the advantages in using ReactJS over ASP.NET CORE?

ReactJS is high performance and rapid development client side framework, you can use it throw asp.net core or any other server side framework to handle client side operations.

Would not that additional library & its components, slow down the page load, comparing plain Razor Views?

ReactJS designed to be a single page application, and this kind of apps is more faster than multiple page applications, also ReactJS processing the DOM in different and smarter way.

If you want to use ReactJS in asp.net core you must keep in mind that asp.net core is the api part just to return the data (json or xml) or to receive your ajax request to post data.

All clients side parts will handled by ReactJS, no razor views, you can have only one to reference your reacts application or simply you can reference it using plain html page.

like image 26
Mohammad Ghanem Avatar answered Oct 09 '22 03:10

Mohammad Ghanem