Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I am currently at the beginning process of starting a new application and am quite new to MVC and Angular. So far i have created a custom authorize attribute using asp.net MVC, this enables me to use the [Authorize] tag. Is it possible to use with an AngularJS front-end?

Any resources that will point me in the right directions would be appreciated.

share|improve this question
1  
I suggest you see this presentation. I believe it answers your questions very well. goo.gl/FXamny – AlexRebula Jul 12 at 13:17

2 Answers 2

up vote 1 down vote accepted

AngularJs is really good for single-page-applicaitons (SPA). So just separate your front-end and back-end layers. Use Angular to implement all the views and front-end stuff. Use ASP.NET WebAPI to expose REST API for front-end (and maybe mobile) app.


A few useful links:

Angular Routing module

ASP.NET WebAPI Bearer token authorization with AngularJs

Routing in SPA with AngularJs

share|improve this answer
    
Thanks il take a look now. – Adam Wilson Mar 17 at 12:12
    
But as I understand Andrei wants to benefit from other great ASP.NET MVC features like authentication and authorization, so your answer is good but does completely answer his question. I'll try to answer myself. – AlexRebula Jul 12 at 13:22

The answer is YES! So you can still benefit from ASP.NET MVC features like authentication and authorization etc. and still use AngularJS on the client.

I actually had the same question and after a bit of research I discovered the following.

It's true we should embrace SPAs (single page apps) but at the same time we should not just discard mature server-side frameworks such ASP.NET MVC. You can simply have a hybrid web app or mini SPA as we also call them. These web applications use normal ASP.NET MVC routing to show views and then, once the view loads you can leave all the responsabilities to AngularJS. Miguel Castro uses the term SPA silos. Plus you can benefit from AngularJS' routing as well. Miguel Castro also explains how to use them both together to get the best of server and client side. I really suggest seeing his presentation (link below).

In that way you can still benefit from ASP.NET MVC great features like Authentication, Authorization and others but still have AngularJS run your views.

I got this answer on the following locations that you definitely should check out:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.