Course details

AngularJS and ASP.NET 5 MVC 6: Data Persistence, Validation, and Security

AngularJS and ASP.NET 5 MVC 6: Data Persistence, Validation, and Security

Target Audience
Expected Duration
Lesson Objectives
Course Number
Expertise Level

Data persistence is an important aspect of multi-tier web applications, and appropriate validation and security are crucial to any software application. In this course, you'll learn how to use Entity Framework 7 to persist data to a database. You'll learn how to use the built-in features of AngularJS to implement validation in the SPA created with AngularJS and ASP.NET Web API. You'll use ASP.NET validation attributes in the Web API. You'll update the database and controllers to take account of the validation. You'll also implement security – in this case you'll use ASP.NET Identity. Finally, you'll learn how to force login using the Authorize attribute, forward claims data from ASP.NET to AngularJS, and secure API controller actions.

Target Audience
Developers familiar with AngularJS, C# and Visual Studio who want to use AngularJS and ASP.NET's MVC 6 Web API and Entity Framework 7 to create SPAs


Expected Duration (hours)

Lesson Objectives

AngularJS and ASP.NET 5 MVC 6: Data Persistence, Validation, and Security

  • start the course
  • add the Entity Framework (EF) 7 NuGet packages to the project
  • create an Entity Framework DbContext class
  • register the EF DbContext with the application services
  • configure the database connection string in the Config.json file
  • avail of dependency injection to enable the Web API controller to use the DbContext class
  • use the command prompt or NuGet Package Manager Console to perform database migrations
  • use built-in features of AngularJS to configure client-side form validation
  • update an ASP.NET model to use validation attributes
  • update the Web API controller on the server to check for a valid model state and display validation messages
  • update the client controllers to show validation messages coming from the server
  • store app data persistently as well as validate data on client and server side
  • enable ASP.NET Identity by adding required packages and updating ConfigureServices() method in startup file to register services with the Dependency Injection framework
  • modify the DbContext class to inherit from IdentityDbContext to use ASP.NET Identity
  • modify the startup file to create the database, sample data, and add users at startup
  • modify the application to serve the Angular index files as a MVC view
  • force user login by using the Authorize attribute on the Home controller
  • pass claims data for users from ASP.NET to AngularJS
  • modify the application to add functionality for authenticated users to log out
  • modify the application to restrict access to web API endpoints based on authentication and claims
  • configure use of EF7 and add validation and security to an app using AngularJS and MVC6 Web API
  • Course Number:

    Expertise Level