Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC validation with Angular VS Razor

ASP.Net MVC together with Custom Attributes in your model and with Razor, lets you just write an HTML Helper like @Html.ValidationMessageFor(model => model.MyAttribute) to validate each field.

AngularJS intends to render everything on the client side, so we don't have access to Razor and all the javascript validators generated for free. We have to code everything again by hand, and we don't have the guarantee that this validation is in sync with the server side validation, which we had with Razor.

How will we overcome this GAP?

like image 676
user3864332 Avatar asked Sep 08 '14 21:09

user3864332


People also ask

Is Razor pages better than MVC?

From the docs, "Razor Pages can make coding page-focused scenarios easier and more productive than using controllers and views." If your ASP.NET MVC app makes heavy use of views, you may want to consider migrating from actions and views to Razor Pages.

Does ASP.NET MVC use Razor pages?

A Razor Page is very similar to the view component that ASP.NET MVC developers are used to. It has all the same syntax and functionality. The key difference is that the model and controller code is also included within the Razor Page itself. It is more an MVVM (Model-View-ViewModel) framework.

Why Angular is better than ASP.NET MVC?

Angular does away with the problem of mixing client and server code within the same file. Razor syntax allows the developer to embed client and server code within the same file and to use server-side logic to control the client-side presentation. Angular decouples the client-side processing completely from the server.

Can we use Angular with ASP.NET MVC?

To load Angular in ASP.NET MVC, include the script references of Angular core modules and Syncfusion JavaScript asset files in _Layout file , and load the component in index. cshtml like the following code snippets.


1 Answers

This solves my problem:

https://github.com/alisabzevari/ngval

If we want to go deeper (which I don't need now), we can have this:

https://bitbucket.org/asiemer/angularjs.mvc/wiki/Home

like image 163
user3864332 Avatar answered Sep 18 '22 15:09

user3864332