angularjsasp.net-mvcmodel-view-controllermultiple-forms

AngularJS vs multiple forms in ASP.NET MVC


I'm building a complex job application. And I want it to be a SPA. I'm using AngularJS with Asp.net MVC (not web API). Everything is working so far, but I realized that I can no longer take advantage of a lot of features that ASP.NET MVC provides. So far I know I have to write my own code for these features:

  1. all validation have to be on client side. I can't reuse some attributes I wrote in C#.

  2. [ValidateAntiForgeryToken] attribute no longer work.

  3. I can't use classes that generated by entity framework directly. It will give "circular reference" error for that.

I almost regret to take this approach. It's nice to have 2-way binding, but I have to write a lot of extra code that I could have avoided if I don't use angularJS. I can write multiple forms in one page and achieve the same result like shown here:

Multiple Forms in same page ASP.net MVC.

Can you tell what other MVC features I still have to write code for? when should I use angularJS and when should I use ASP.NET multiple forms on the same page?

Thanks


Solution

  • You can ease the pain of those listed points, but still, it might be better to decide what's better for you from the beginning - rendering views client-side (angular) or server-side (mvc).

    Anyways, there are known solutions for some of the listed issues. Angular directive for MVC validation attributes: https://github.com/alisabzevari/ngval

    For the [ValidationAntiForgeryToken] here is also a solution: https://julianjelfs.wordpress.com/category/mvc/

    I have not understood the thing regarding multiple forms (I believe it's unrelated to angular), so skipped on this..