Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

MVC4 with AngularJS

Why combine a server-side MVC with a client-side MVC?

Honestly the ASP.NET MVC advocacy doesn't make sense to me. It is a solution that half brings .NET developers into the modern era. Using it purely as a service layer is that project essentially trying to maintain relevance in the face of irrelevance.



Yep, half-way sounds about right. By default ASP.NET doesn't allow you to GET json, have to override that.

Also the routing is not RESTful at all and doesn't handle nesting very well, so you have to find a 3rd party routing library or role your own.


The reason it doesn't allow you to do JSON GET requests is because of the possibility of hijacking. http://haacked.com/archive/2009/06/24/json-hijacking.aspx Not allowing this by default is a good thing. It will make developers look up the reason it's not working, and hopefully not return an array from the get request. They could have done a runtime exception only if an array was returned, but that's a matter of opinion.


Why combine? Because the server side infrastructure is a lot more flexible with MVC (than WebForms) and follows how HTML is supposed to work.

If you're developing an API or service, use WebAPI instead. It solves most of the issues people have with MVC. MVC is still simple and easy to use to create services with, and I'd still recommend it to people.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: