Real World Asp.Net WebApi Applications

25
ASP.NET Web Api How to build real world single page applications

description

Best practices and insights for building great Asp.Net WebApi applications

Transcript of Real World Asp.Net WebApi Applications

  • 1.How to build real world single pageapplications

2. Git AppHarbor PaaS MongoDB integration IoC/Dependency Injection Tests with nUnit & Moq CI + CD Repository Pattern Exception Management Authentication & Authorization 3. Bootstrap.MVC for responsive design Backbone.jsclient MVC lib Client Side session management Client side authentication 4. Build and deploy an App in the Cloud 5. WebApi is Self Hosted and more flexible WebApiHas Content Negotiation Separation of concerns Allows detaching the website from the Api 6. UserQuestionVote Name QuestionText UserId Password IsOpenToVotes Answer PassSalt List AccessToken 7. The Api 8. User Model: public class User : Entity public string Name { get; set; } public string Password { get; set; } public string PasswordSalt { get; set; } public string AccessToken { get; set; } 9. User Api Model: public class User public string Id { get; set; } public string Name { get; set; } public string AccessToken { get; set; } 10. Use AttributeRouting nuGet Packagepublic class SampleController : ApiController{[GET("Sample")]public List Index() { /* ... */ }[POST("Sample")]public void Create() { /* ... */ }[PUT("Sample/{id}")]public void Update(int id) { /* ... */ }[Route("Sample/Any-Method-Will-Do")]public string Wildman() { /* ... */ }} 11. Main 12. DependencyMain Injector 13. Pros Decoupling Easy Testing, Isolating and Mocking Cons Complicates the code New set of bugs 14. Add StructureMap.MVC4 nuGet Package to the website Build classes with IoC in mind Add Repository Registry Add Registry to Ioc.cs in Depedency Resolution folder 15. Not a part of Asp.Net. Its just a best practice Allows: Code reuse Decoupling IoC/Dependency Injection Current Standard Low learning curve for developers 16. void Add(IEnumerable entities) IQueryable All(Expression> criteria) void Delete(Expression> criteria) void Update(IEnumerable entities) ... 17. The Client 18. Backbone.js Knockout.js Javascript.MVC Ember.js Angular.js Batman.js Sammy.js YUI 19. Twitter Bootstrap Foundation3 by Zurb HTML5 Boilerplate LessFramework 20. Attribute Routing Twitter Bootstrap Twitter Bootstrap Starter Layout Page Great Backbone.js Book 21. ChromeExtensions Dev Http Client Edit this Cookie Clear Cache JSON View Responsinator 22. [email protected] @fe_rdt Github: EffieArditi