Angular.js and ASp.Net MVC Advise

2,524 views
Skip to first unread message

dev mondo

unread,
May 16, 2013, 8:55:02 PM5/16/13
to ang...@googlegroups.com

Hi, 

I am a long time ASP.Net Developer, right now I have my own developed CMS, and the way I created the Admin is to be a single page Application utilizing the following:

-Kncokout.js

-Hisory.js

-Jquery.js

-and a lot of jquery plugins to handle, querystring, url and some nifty UI stuff, like select2, Redactor.js, etc...

 

Now my current structure lies around Modules, meaning that I have Blog Module, Gallery Module, and Newsletter Module etc…

 

Each Module has it is own, business logic, settings and Database structure as any other project, and I enable options per client through configuration class for each module.

 

The way I load the UI is that I use ASP.Net MVC razor Partial Views and I send them as JSON string using Jquery AJAX and ASP MVC Controller and then utilizing Jquery I just fill the Module Container Div with the JSON Result.

 

The benefit of this approach is that with Razor Views I can have great control and flexibility over the UI Logic. for example   if user do not have access permission to add record, I can  disable the rendering of Add Button in Razor before it reaches the browser, also I can fill Countries, and other Dynamic Drop down lists on the fly.

 

On Data binding side Knockout does all the work and it is great, but after I got introduced to Angular.js I was blow away by the natural feel of Data binding and the elegance of the frame work  and wealth of other built in functions like routing, AJAX, etc…

 

Right now, I want to shift my code to Angular.js. However, I am confused and would appreciate it if someone could help on the following:

 

-Angular.js can load Views from normal HTML files, this is great, but as I mentioned above I will lose the ability to do complex Business logic and showing/hiding pieces of code to user on server side. So should I keep using Razor views to accomplish what I need, and load the views from server side, or is there something better?

 

-another problem I am having with Angualr.js is that it cashes views, and this makes it troublesome when I update the html and upload new version to server, not to mention permission issues if I change them.

 

-another  problem I am having  with Angular.js right now is that it does not lazy load controllers, directives, etc… and the way I am developing right now is that I load JavaScript logic required files with each razor view, this safes user bandwidth and make code grouped better, because not all pages use or have the same requirements. Again this will not work with angular, in other words I want to load controllers, directives, filters when they needed.

 

Overall, I am tired of knockout.js hacks to make things work and endless Dom manipulations, which were Angular.js Shines, but at the same time, I love the ability to makes business decisions on the server side in the views, so I need some guidance.

 

Sorry if my post is long or not descriptive enough but this seemed the best place to acquire some knowledge about best practices with Angualr.js before I make this huge shift.

 

 

 Thanks in advanced.

 

 

 

 

Message has been deleted

dev mondo

unread,
May 21, 2013, 4:53:13 PM5/21/13
to ang...@googlegroups.com
Hi again, 
on help on this please ?

Tony Polinelli

unread,
May 21, 2013, 5:57:25 PM5/21/13
to ang...@googlegroups.com
On Tue, May 21, 2013 at 1:53 PM, dev mondo <devm...@hotmail.com> wrote:
Hi again, 
on help on this please ?


On Friday, May 17, 2013 4:55:02 AM UTC+4, dev mondo wrote:

Hi, 

I am a long time ASP.Net Developer, right now I have my own developed CMS, and the way I created the Admin is to be a single page Application utilizing the following:

-Kncokout.js

-Hisory.js

-Jquery.js

-and a lot of jquery plugins to handle, querystring, url and some nifty UI stuff, like select2, Redactor.js, etc...

 

Now my current structure lies around Modules, meaning that I have Blog Module, Gallery Module, and Newsletter Module etc…

 

Each Module has it is own, business logic, settings and Database structure as any other project, and I enable options per client through configuration class for each module.

 

The way I load the UI is that I use ASP.Net MVC razor Partial Views and I send them as JSON string using Jquery AJAX and ASP MVC Controller and then utilizing Jquery I just fill the Module Container Div with the JSON Result.

 

The benefit of this approach is that with Razor Views I can have great control and flexibility over the UI Logic. for example   if user do not have access permission to add record, I can  disable the rendering of Add Button in Razor before it reaches the browser, also I can fill Countries, and other Dynamic Drop down lists on the fly.

 

On Data binding side Knockout does all the work and it is great, but after I got introduced to Angular.js I was blow away by the natural feel of Data binding and the elegance of the frame work  and wealth of other built in functions like routing, AJAX, etc…

 

Right now, I want to shift my code to Angular.js. However, I am confused and would appreciate it if someone could help on the following:

 

-Angular.js can load Views from normal HTML files, this is great, but as I mentioned above I will lose the ability to do complex Business logic and showing/hiding pieces of code to user on server side. So should I keep using Razor views to accomplish what I need, and load the views from server side, or is there something better?

 


You can serve flat templates (rendered by razor) if you wish, but this is a clunky way, you you will lose all dynamic data updating. Serving data as a seperate asset (JSON) and rendering client side is much more flexible. 
 

-another problem I am having with Angualr.js is that it cashes views, and this makes it troublesome when I update the html and upload new version to server, not to mention permission issues if I change them.

 


I add a cache killer - ?cache={{killer}}  - then $scope.killer = Math.floor(Math.random() * 1000);

to every request. Define the killer in the top level controller and it is available in all templates. It will change on page refresh (which isnt THAT often in angular) - any better solutions welcome
 

-another  problem I am having  with Angular.js right now is that it does not lazy load controllers, directives, etc… and the way I am developing right now is that I load JavaScript logic required files with each razor view, this safes user bandwidth and make code grouped better, because not all pages use or have the same requirements. Again this will not work with angular, in other words I want to load controllers, directives, filters when they needed


Arranging the app to render on client side will reduce your download significantly already (no re-serving the header,nav, etc. with every page). So loading all logic at once isnt a bad tradeoff imho. Although you can look at using require.js - there are a lot of threads on this list about this. 

 

Overall, I am tired of knockout.js hacks to make things work and endless Dom manipulations, which were Angular.js Shines, but at the same time, I love the ability to makes business decisions on the server side in the views, so I need some guidance.


Its hard to give advice without knowing the situation. Rendering client side has its advantages, obviously how you serve your data for each page requires serverside logic (security). This is where you business decisions should be - defining the served data. 

  Sorry if my post is long or not descriptive enough but this seemed the best place to acquire some knowledge about best practices with Angualr.js before I make this huge shift.


cheers 

 

 

 Thanks in advanced.

 

 

 

 

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Tony Polinelli
http://touchmypixel.com

dev mondo

unread,
May 22, 2013, 1:45:20 AM5/22/13
to ang...@googlegroups.com, to...@touchmypixel.com
Tony, 
thanks a lot for the answers, it really gave me hope about what i should do in terms of best practices 

Daniel Lidström

unread,
May 22, 2013, 6:21:28 AM5/22/13
to ang...@googlegroups.com, to...@touchmypixel.com
On Tuesday, May 21, 2013 11:57:25 PM UTC+2, Tony Polinelli wrote:

You can serve flat templates (rendered by razor) if you wish, but this is a clunky way, you you will lose all dynamic data updating. Serving data as a seperate asset (JSON) and rendering client side is much more flexible. 
 

-another problem I am having with Angualr.js is that it cashes views, and this makes it troublesome when I update the html and upload new version to server, not to mention permission issues if I change them.

 


I add a cache killer - ?cache={{killer}}  - then $scope.killer = Math.floor(Math.random() * 1000);

to every request. Define the killer in the top level controller and it is available in all templates. It will change on page refresh (which isnt THAT often in angular) - any better solutions welcome
 
I use Cassette to handle my partial views. The views are included as scripts in my main page and I use jQuery to fetch them: template: $('#add-delegation-template').html()
Of course this means loading all partial views for the page right away. For me, however, that is not a problem.

/Daniel

Arturo Hernandez

unread,
May 22, 2013, 12:14:57 PM5/22/13
to ang...@googlegroups.com, to...@touchmypixel.com
On top of what what has already been suggested, I would recommend you use the MVC4 webapi, and start passing your models to the client via JSON. Use the $resource object to wrap your RESTful api.

var Services = angular.module('app.services', ['ngResource']).
    factory('planetsDB',function ($resource) {
        return $resource('api/planets/:Id', {}, {
            update: { method: 'PUT' }
        });
    });

dev mondo

unread,
May 23, 2013, 2:25:09 AM5/23/13
to ang...@googlegroups.com, to...@touchmypixel.com
Thank you all for these great advises, i think i understand it all, but the thing that bugs me the most is the lack of utilizing some of the great aspects about Razor and going totally client side in terms of Views, i thought there would be a better way to utilize the best of 2 words :(

Ron Buchanan

unread,
May 23, 2013, 9:57:50 AM5/23/13
to ang...@googlegroups.com
I started a large project about 2 months ago with Angular. It uses only one .NET MVC controller and view; Home. The _Layout.cshtml view contains the ng-app and ng-view directives. After that, there is an "app" folder where Angular takes over. This project is organized similar to yours via modules. I started mine based on this great seed project that has security, i18n, and a lot of other stuff built in ... https://github.com/angular-app/angular-app.

I found that the less I used of .NET, the better. .NET is just a container that provides me a web context for things like session and server-side security. All of our service calls go to a service controller that is very basic and lightweight. We had thought about using the Web API, but it just seemed like a lot of overhead for nothing. The more I let go of .NET for the client and just worked in Angular, the better things got.

-- 
Cheers,
Ron

Alec Whittington

unread,
May 23, 2013, 10:00:02 AM5/23/13
to ang...@googlegroups.com
First off - welcome to using AngularJS. It will be a steep learning curve, but a short one. I'm a longtime ASP.NET MVC developer as well, using it since it was first announced in Dec 2007. 

I used to use a very similar model of develop as you've laid out here, but no longer use it. Here is my current Development Stack:
  • ASP.NET MVC
    • I use this so that I have the flexibility to have non-angularjs areas, e.g. static areas
    • Core Routing e.g. /AboutUs
  • AngularJS
    • Depending on the app, I might use it as a SPA or might use it in just a particular portion of the application, such as you are doing with the Admin area
  • ServiceStack
    • I am not a fan of ANY of the Microsoft web services (ASMX, WS-*, WCF, Web Api). They are all by far way too complicated for what they should do
    • Simple RESTful routing and URI's
    • Can return in multiple formats from one service with nothing more than the client requesting a specific content type
  • TypeScript
    • Helps me write more maintainable JavaScript as well as provide compile time checking
    • You do not have to learn a new language ,e,g, CoffeeScript, to use it. 
As far as some of your questions:
  • You can create incredibly complex UIs with AngularJS that have complex Business Logic. But you need to ask yourself, is your current UI doing too much right now? In my experience, complex business logic does not belong on the UI. The UI should react to changes in your Model or values in your model. 
  • If your doing DOM Manipulation in your ng-controllers, you're doing it wrong. Look into using custom directives as well as the built-in directives. It is very tempting at first to keep following the jQuery model we've all come used to in our ng-controllers. Don't do it.
  • For Dynamic loading of your scripts, look into using AMD with Angular. You can come up with convention based routing that can help load your scripts as you need them. Dan Wahlin has a nice article on this, http://weblogs.asp.net/dwahlin/archive/2013/05/22/dynamically-loading-controllers-and-views-with-angularjs-and-requirejs.aspx - while he only shows loading controllers, it could be modified to dynamically load services as well.
It will take a little bit of time to come to speed, but you will have the "ah ha" moment and Angular will just make sense.

Hope this helps
Alec Whittington

Ron Buchanan

unread,
May 23, 2013, 11:34:12 AM5/23/13
to ang...@googlegroups.com
+1 for ServiceStack mention. If we would not have already had something in place, I would have used ServiceStack.

--
Cheers,
Ron

Tony Polinelli

unread,
May 23, 2013, 8:31:38 PM5/23/13
to ang...@googlegroups.com
aaah didnt people just give you advise?... be more specific?


On Tue, May 21, 2013 at 6:33 AM, dev mondo <devm...@hotmail.com> wrote:
Any help on this matter please ?


On Friday, May 17, 2013 4:55:02 AM UTC+4, dev mondo wrote:

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Message has been deleted

Alec Whittington

unread,
May 24, 2013, 9:45:40 AM5/24/13
to ang...@googlegroups.com, to...@touchmypixel.com
You are going to struggle with this until your mind wraps around client dev and angular. While razor was a huge step in the right direction for ASP.NET MVC over the WebForms view engine, it still encouraged putting too much business logic in your presentation. For the most part, your presentation (HTML) should be dumb. Angular will allow you to dumb down your UI, allowing it to react to changes in the model. This means you need to do more in your controller (server side) before you ship over JSON.
Message has been deleted

Alec Whittington

unread,
May 31, 2013, 12:16:33 PM5/31/13
to ang...@googlegroups.com
Mondo,
��� Since you would most likely not be doing a true SPA, I'll explain how I perform a "section" / page load. I work on very large enterprise applications, from billing systems to healthcare, so in many cases a true SPA is not practical. In these cases, I try to break down the application into one or more Angular Applications. Yes, you can have more than one Angular Application (even in the same page).

Within each of these "sections" as I like to call them, they are generally initiated by a single ASP.NET MVC view. When the view loads, it is loading the ng-app, which uses routing (angular, not asp.net mvc) to load the initial view into the ng-view. When that controller gets loaded, it makes a call via $http to a ServiceStack end point (or controller action) that returns what the controller (ng-controller) to function. The payload being returned from the server side is JSON.

Here is how I would handle it:
  • Languages - That static method you are calling in razor is a classic example of how not to do it. Your controller already knows who the user is, so your View Model should've had a list of SelectListItems that represented the languages that the user could see.

    When you do it in Angular, you would use that paradigm. In the server method that delivers your initial angular controller payload, the model it returns should have a value that represents those languages as an array of json objects. Your angular view would have a drop down tied to those.

  • Form Fields on Permissions - You'd do this very similarly to the languages, pass the user permissions back in the initial payload to the controller. Then use ng-show="methodOnControllerScope(model.permissions)" on the form fields. This might not be the most secure way, but it is a starting point that you can build from. Biggest thing here is not allowing the user to modify those permissions.

  • Same as above. In this case, I would have a root controller that manages the overall application stuff (menus, navigation, etc). You would have a property on the controllers model that would represent currentLanguageFormatting and now have ng-class="currentLanguageFormatting" on your <body> tag. When they select a language that is RTL, just set that property to "rtl".

The thing you need to keep in mind is that you have to give Angular controllers what it needs. This is no different than razor, as you would be passing a view model. Now you are just passing this to the controller.
--
Thank you,
Alec


Friday, May 24, 2013 1:09 AM
@Rob and Alec, this is really really great advice from you guys as fellow ASP.Net Developers

it is truly a mind-shift and steep learning curve but it is really feeling better than Knockout, really better!, i will follow your suggestions thoroughly.

but if you could kindly advise on the following i would totally appreciate it

the �business logics i need are as follows

-for example i have Languages list that is defined in static class in c#, right now what i do is in razor i show allowed languages based on the logged in user permission, this is easy as i have c# static method that i can call from Razor and it will return those allowed languages, but now with Angualr.js only i don't know how to do it, the only way i see for such a thing is make ajax calls after view loads to achieve the same thing, please correct me on that.

-the other thing is as i mentioned before, i prevent a user to see some form fields based on his permissions

-i have multi lingual app and based on user saved settings stored in db, if he chooses right to left language, i add ".rtl" class to document, Body again this is easy by calling a c# mthod from razor that in return calls db and return user's perferred language�
so all in all what is the right way to achieve this with Angualr


On Thursday, May 23, 2013 7:34:12 PM UTC+4, Ron Buchanan wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/ypr5GSliXas/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
�
�

dev mondo

unread,
Jun 1, 2013, 4:32:55 PM6/1/13
to ang...@googlegroups.com
Alec, 
much appreciated your input, and you enlightened my mind on new way of thinking, all in all i see that i have to shift my own thinking to Angular first then Server when needed.

on the security part, i see that the right solution is to have Server Validation and ViewModel that depends on User's permissions.

the biggest issue for me here, is to find a way to send these Application parts like Countries List, Languages list with each controller alongside the Model itself without repeating myself 

Alec Whittington

unread,
Jun 3, 2013, 9:09:26 AM6/3/13
to ang...@googlegroups.com
Mondo,
��� NO problem. It took me a little bit of time before the 'light bulb' clicked on for me with Angular. I was very much in a similar situation as you. I've been working with MVC since 'The Gu' announced it in Dec 2007. My mind was focused on delivering it via the server. Once you get used to working with Angular, it will become more natural to start thinking client first, rather than server first.

In reality it is really a small shift in your logic, you will still use best practices with ASP.NET MVC such as using ViewModels and FormModels for sending and receiving data from the client. It's just that now, most of your controller action methods will return JSON rather than a compiled view. This is why I recommend using ServiceStack with Angular. I segregate my ASP.NET MVC applications with ServiceStack. Anything needing a view that does not use Angular I use regular ASP.NET MVC controllers and views. Anything using Angular communicates that calls into the Backend calls into a ServiceStack service.

As far as sending the lists to the front, in my applications I generally have some sort of 'SiteContext' that will hold lists of objects that the site may need. The criteria for being placed into the SiteContext is that the list must be small - say under 50 or so (Country list being an exception to that) - the objects cannot have a huge object graph associated with it. The next criteria would be that the items in the list must not change frequently (adding, removing, editing).

When the site loads for the first time, these lists get loaded and saved in the SiteContext. When I need to send them to the client I just include them in my ViewModel. I do not worry about DRY with these types of things. Since C# can only inherit from one class, you can quickly end up with large number of classes just trying to keep it DRY.� I worry about DRY in general, just not for little things like this where the effort is not worth the result.

You have to remember that at the end of the day, our clients expect us to deliver and deliver in a timely manner. I follow best practices (SRP, DRY, TDD, IoC, etc) for 90% of everything I do in the application, but you have to find that balance between delivering and making it 'technically' perfect. I do not subscribe to the Joel Spolsky 'Duct tape' programming of just get it done. But with 16 years experience writing software, I know that we do not live in a perfect world and cannot always take the time to follow every design pattern / design principal out there.

If you've got more questions, please don't hesitate to ask. It's getting easier and easier to find more of us .NET guys using Angular, but there still are only a few of us.
--
Thank you,
Alec


Saturday, June 01, 2013 1:32 PM
Alec,�
much appreciated your input, and you enlightened my mind on new way of thinking, all in all i see that i have to shift my own thinking to Angular first then Server when needed.

on the security part, i see that the right solution is to have Server Validation and ViewModel that depends on User's permissions.

the biggest issue for me here, is to find a way to send these Application parts like Countries List, Languages list with each controller alongside the Model itself without repeating myself�
Friday, May 31, 2013 9:16 AM
Mondo,
��� Since you would most likely not be doing a true SPA, I'll explain how I perform a "section" / page load. I work on very large enterprise applications, from billing systems to healthcare, so in many cases a true SPA is not practical. In these cases, I try to break down the application into one or more Angular Applications. Yes, you can have more than one Angular Application (even in the same page).

Within each of these "sections" as I like to call them, they are generally initiated by a single ASP.NET MVC view. When the view loads, it is loading the ng-app, which uses routing (angular, not asp.net mvc) to load the initial view into the ng-view. When that controller gets loaded, it makes a call via $http to a ServiceStack end point (or controller action) that returns what the controller (ng-controller) to function. The payload being returned from the server side is JSON.

Here is how I would handle it:
  • Languages - That static method you are calling in razor is a classic example of how not to do it. Your controller already knows who the user is, so your View Model should've had a list of SelectListItems that represented the languages that the user could see.

    When you do it in Angular, you would use that paradigm. In the server method that delivers your initial angular controller payload, the model it returns should have a value that represents those languages as an array of json objects. Your angular view would have a drop down tied to those.

  • Form Fields on Permissions - You'd do this very similarly to the languages, pass the user permissions back in the initial payload to the controller. Then use ng-show="methodOnControllerScope(model.permissions)" on the form fields. This might not be the most secure way, but it is a starting point that you can build from. Biggest thing here is not allowing the user to modify those permissions.

  • Same as above. In this case, I would have a root controller that manages the overall application stuff (menus, navigation, etc). You would have a property on the controllers model that would represent currentLanguageFormatting and now have ng-class="currentLanguageFormatting" on your <body> tag. When they select a language that is RTL, just set that property to "rtl".

The thing you need to keep in mind is that you have to give Angular controllers what it needs. This is no different than razor, as you would be passing a view model. Now you are just passing this to the controller.


dev mondo

unread,
Jun 4, 2013, 10:24:23 AM6/4/13
to ang...@googlegroups.com
Alec, 
seriously with each Post of yours i get new light bulbs, i am very lucky to have a .NET oriented guy to give his advises on this, seriously appreciated.

in terms of Service Stack, don't you think that WebAPI is similar ? 

saving frequently used objects in AppContext is great Idea, and i started exploring it more now after your Advise and try to decide which goes there and which dont.

the problem as you said, is that in c# you only inherit from one class, i am exploring the idea of sending Dynamic Object as JSON, this way i can inject what ever i want to the sent Model through action Filters or through Code, specially that now i don't use Razor so there is no need for strongly typed ViewModel, what do you think ?

on your advise about best practices, i could not agree more, you are perfectly right and this is how real world works :)

Dan Barua

unread,
Jun 4, 2013, 11:15:09 AM6/4/13
to ang...@googlegroups.com
ServiceStack is like WebAPI except that it doesn't feel like smashing yourself over the head with a brick.

Alec Whittington

unread,
Jun 4, 2013, 11:17:17 AM6/4/13
to ang...@googlegroups.com
Mondo,
    Thanks for the kind words. I enjoy helping when I can.

ServiceStack make making a Restful API much simpler than Web Api. As Glenn Block has pointed out, the Web Api was never designed to be "RESTful", it was designed to be a layer over HTTP. With that comes extra work that must be done to make things work, even for a simple problem. ServiceStack as provides other added functionality out of the box, Caching and Session are two as is one of the fastest JSON Serializers for .NET.

I choose to use ServiceStack to interface with all AJAX requests from the browser as all I ever return is either JSON or a web request error with a status code. I like how I have clearly separated Request and Response objects as I've worked with the concepts of FormModels (Request Objects) and ViewModels (Response Objects) for years. It fits into my way of thinking already. I've also been using AttributeRouting with ASP.NET MVC for years and like how ServiceStack can make use of similar Attributes for declaring the service endpoints (routes).

--
Thanks,
Alec


Tuesday, June 04, 2013 7:24 AM

Alec Whittington

unread,
Jun 4, 2013, 11:17:44 AM6/4/13
to ang...@googlegroups.com
Yeah - What he said.
--
Thanks,
Alec


Tuesday, June 04, 2013 8:15 AM
ServiceStack is like WebAPI except that it doesn't feel like smashing yourself over the head with a brick.

On Tuesday, 4 June 2013 15:24:23 UTC+1, dev mondo wrote: --
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/ypr5GSliXas/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Tuesday, June 04, 2013 7:24 AM

Joel Musheno

unread,
Jun 4, 2013, 11:24:40 AM6/4/13
to ang...@googlegroups.com
As another of the .net guys who've drunk the angular koolaid, I can honestly say that it's been a pleasure using it. 

Our back end is all WebAPI so that we can interface with our back end ERP system (placing orders and dealing with business logic hooks). I wish I would have taken the opportunity to use ServiceStack, but I chose the MS branded solution for that one. If you want to see what we've done: https://github.com/joelmusheno/AptifriedWebApi

Our front end is a node.js server that uses the express package to run our angular app. (It's in a private company repo)

It's a paradigm shift for me professionally, being a .netter. 

I can try to give you some pointers on what we're doing, but we've forgone the rendering engine of .net at all and we're using node for that. It scales out amazingly well. You just have to remember that all your api calls are atomic actions.

Joel

Joel Musheno

unread,
Jun 4, 2013, 11:28:25 AM6/4/13
to ang...@googlegroups.com
hahhahaha! 

I haven't quite had that problem yet.. though, as I said, I should have taken this opportunity to use ServiceStack- it would have probably been a better solution. 

WebAPI has been quite enough for us as of yet, though. Has handled load well and was an easy sell to our infrastructure guys, as it had the MS brand on it.

Daniel Lidström

unread,
Jun 4, 2013, 11:30:20 AM6/4/13
to ang...@googlegroups.com
Finally someone who could describe the advantages of servicestack, not just the usual webapi bashing. Thanks for the nice summary. I don't think REST is always the thing to aim for and I'm quite happy with what webapi gives me. Nevertheless, I'll have to take a look at servicestack now :-)

Daniel


On Tue, Jun 4, 2013 at 5:17 PM, Alec Whittington <alec.whi...@gmail.com> wrote:

Mondo,
    Thanks for the kind words. I enjoy helping when I can.

ServiceStack make making a Restful API much simpler than Web Api. As Glenn Block has pointed out, the Web Api was never designed to be "RESTful", it was designed to be a layer over HTTP. With that comes extra work that must be done to make things work, even for a simple problem. ServiceStack as provides other added functionality out of the box, Caching and Session are two as is one of the fastest JSON Serializers for .NET.

I choose to use ServiceStack to interface with all AJAX requests from the browser as all I ever return is either JSON or a web request error with a status code. I like how I have clearly separated Request and Response objects as I've worked with the concepts of FormModels (Request Objects) and ViewModels (Response Objects) for years. It fits into my way of thinking already. I've also been using AttributeRouting with ASP.NET MVC for years and like how ServiceStack can make use of similar Attributes for declaring the service endpoints (routes).

--
Thanks,
Alec


<compose-unknown-contact.jpg>
Tuesday, June 04, 2013 7:24 AM

dev mondo

unread,
Jun 4, 2013, 5:44:53 PM6/4/13
to ang...@googlegroups.com
Thanks for all the .Netters here who shimmed in,

Alec, your argument is really great, and i started reading about servicestack, specially that myself too i am using Attribute Routing.

the thing that bugs me the most and of course because i am novice is that i build CMS system based on Modules so i wont repeat my self with each new Client, the thing that i want to achieve is for example i create Blog Module where client can post articles, etc,,, all is fine and i know how to do it, now comes the part which is i don't know how to make it extendible Per Client's requirements, for example one client asks me that he does want to add PDF file upload with each article he adds, here is where i don't know how to make the Blog Module extendible, in other words i don't want to create a new Blog Module that have this extra functionality, i want to know how i can extend the controller to deal with this extra requirement. 


i hope i was clear and i appreciate any input on this.

Socratis21

unread,
Jun 6, 2013, 7:15:30 PM6/6/13
to ang...@googlegroups.com
Is there any sample solution/application with ServiceStack and AngularJS ?

Thanks
Reply all
Reply to author
Forward
0 new messages