I am an experienced .net developer and I am very competent using MVC. I have only just read up a little on react.js today and would like to try and get more into it.
Are there any .net MVC developers or there that have mixed a project up with MVC with good results? Most notably to do with validation.
Normally my C# classes have validation attributes on them. And I can mess around with model state errors to do more custom stuff server side.
How would you mix react validation with MVC? Or can it not be done?
EDIT Is there anyway to validate in React using the MVC attributes to save duplication of validation?
ReactJS.NET makes it easier to use Facebook's React and JSX from C# and other . NET languages, focusing specifically on ASP.NET MVC (although it also works in other environments). It supports both ASP.NET 4 (with MVC 4 or 5), and ASP.NET Core MVC. It is cross-platform and can run on Linux via Mono or .
Adding ReactJS JSX file Once added, rename the File extension TSX to JSX. Once the File is added, the following code needs to be added to the file. Here a class HelloWorld is created which extends ReactJS Component. The render function returns an HTML Header element (H1) with a message in it.
If there are any legacy MVC Razor pages, this shiny new React app will integrate seamlessly.
I would recommend having your validation rules server-side, then passing a json object to the client with those validation rules. On the client, you can then create logic to validate these rules, and then once the form is submitted you can run the server-side validation rules and pass back any failed validation to the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With