Sunday, February 7, 2016
In the last post about DependencyInjection I demonstrated how to get from NuGet the unity framework and how to use it in our project. In ASP.NET Core 1.0 we have support for DependencyInjection already build in. The build-in mechanism is abstracted via the IServiceProvider interface and is available throughout all component of the ASP.NET framework, making it easy for us to resolve everything everywhere.
As always, we have several methods of registering types in the service provider.
Instance – The same instance is resolved each time it is called.In this method you have to create the instance once yourself.
Transient - The...
Wednesday, February 3, 2016
When we say we want to build a Web API we have in our mind to build a service that will expose the data in a clean way that every device will be able to address in order to use the data.In this post I will do just that. I have built a service that retrieves some products and together in this post we will build a client that will use this data.
I will build the client using Angular framework. Let`s get started.
Open a new empty web project with no authentication and no need for azure service at the...
Tuesday, February 2, 2016
This will be a really short post as it is really easy to use the unity framework in an ASP.NET Web API application. The application I will build is an ASP.NET 4.5 Web API application which brings products to the controller using Dependency Injection.
Short one on Dependency Injection
Dependency Injection is a design pattern that implement IoC (Inversion of Control) for resolving dependencies for your class. Let us says that your controller is using some repository in order to fetch products from the database. You should not create the repository using the new keyboard as this will result in coupling...
Monday, January 25, 2016
In the last post we added another controller and matching view for CRUD operations.
If you will try to add an empty course name and instructor it will allow you to do this even though it does not make sense. As you can see below I was able to enter an empty fields course.
In this post I will show you how simple it is to add data annotations in order to set and show validations.
I will start with a simple validation, not to allow empty or white spaces as inputs.
Open the Course model and enter the Required attribute above the...
Sunday, January 24, 2016
In this post we will add a new page to our web site.
We will need to define a new model to bring the data from the database, a new controller to that will ready the data to be displayed in our view, and of course a new view to display our data.
Most of this will be done almost completely automatically using the visual studio.
The content we will display in our new page will be courses from our favorite school Hogwarts.
Let us start by adding a new model named Course.
Right click the Model folder and add a class named Course....
Monday, January 18, 2016
The ASP.NET MVC is an open-source framework built by Microsoft over the ASP.NET framework. It`s main goal was to allow the users to use the MVC design pattern in ASP.NET based web sites. The MVC design pattern gives separation between three parts:
Model – the business layer of the application.
View – the view layer of the application. Knows only the data returned from the Controller.
Controller – generates views based on input from the model. Only the controller know both the view and the model.
The connection between the view and the controller is done by the routing mechanism.The view engine used...