HttpClient GetAsync, PostAsync, SendAsync in C#

HttpClient is a library in the Microsoft .NET framework 4+ that is used for GET and POST requests. Let’s go through a simple example of using HttpClient to GET and POST JSON from a web application. First, we will create our client application. We will create a new console app in Visual Studio: Add the¬†System.Net.Http namespace. We will pull down JSON data¬†from a REST service: Now, to read this, we … Continue reading HttpClient GetAsync, PostAsync, SendAsync in C#

Introduction to Model-View-Controller (MVC) and ASP.NET

Model-View-Controller (MVC) is an architectural pattern that separates an app between data, UI and controlling. The pattern was first used on desktop computers and then became popular with web frameworks. There are several other design patterns such as MVVM (model-view-viewmodel) and MVP (model-view-presenter) that we will discuss in another post. The key with MVC is separation of concerns, or SoC, which are the different aspects of the development of an … Continue reading Introduction to Model-View-Controller (MVC) and ASP.NET


ASP.NET Web API allows us to build HTTP services. It can be used with ASP.NET MVC, Web Forms, WCF HttpBinding. The framework is built on ASP.NET. We will go through an example of building a Web API with MVC using Entity Framework. To create a new project, open Visual Studio and create a new ASP.NET Web Application: Now select the type of project. Here we will select Web API: The … Continue reading ASP.NET Web API

Adding Object to EF Model Does Not Display Object

When using the Entity Framework, such as in an ASP.NET MVC application, you may find the model is empty after choosing database objects: Adding new objects using “Add existing entities and relationships to this diagram by dragging them from the Model Browser” does not add the objects. One cause for this is that a primary key has not been defined in the table or view you are trying to use … Continue reading Adding Object to EF Model Does Not Display Object

Return JSON from WebAPI

In WebAPI, you may want to return JSON instead of the out of the box view, which looks like below: The out of the box code for the controller looks like as follows: To display JSON, change View to Json: In running this, you may get the error: “This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a … Continue reading Return JSON from WebAPI

Using Fiddler with Web API

In this post, we will examine using Fiddler to send requests and receive responses from an ASP.NET Web API. I have a Web API sample that looks like the following: There are different HTTP verbs, including: GET PUT POST DELETE The Customers API is very simple – it integrates with a SQL Server table called Customers with 2 fields – CustomerId and CustomerName, with the data: Start Fiddler. We will … Continue reading Using Fiddler with Web API

Update Entity Framework Model

When using Entity Framework, you may need to update the model, if for example you want to add or remove objects such as fields, or you want to refresh the current model. To do this, select the edmx file, and then right click on the designer and select Update Model from Database: From here you will be able to add/remove objects: