Using Postman to Debug a Local ASP.NET Core Web Api

In this post, we will look at how to debug a local API.NET Core Web Api. First, we have a Web Api project in Visual Studio: The URL for this Web Api, when run locally, is https://localhost:44336/api/customers: Let’s add a breakpoint in Visual Studio: Now, let’s debug locally. In Postman, create a new request. We will set the URL to the local one above – https://localhost:44336/api/customers. This will be a GET request. … Continue reading Using Postman to Debug a Local ASP.NET Core Web Api

How to Create a Web API App using ASP.NET Core with App Insights

In this post, we will look at how to create an ASP.NET Core Web Application and host it in Azure with Application Insights. First, let’s open Visual Studio and create a new ASP.NET Core Web Application project: Give the project a name: And select API as the type: We see the project in VS below: Press F5 to run the app. Click Yes if you see the message below: And click … Continue reading How to Create a Web API App using ASP.NET Core with App Insights

Backend service URL is not defined in Azure App Service

In this post, we will look at the error “Backend service URL is not defined” when making a request to an ASP.NET Web API through API Management. I have a .NET Core Web Api with Swashbuckle / Swagger. The Web Api is published to an Azure App Service, and an Azure API Management has this API loaded. We can run a test message using the APIM: We get a 500 … Continue reading Backend service URL is not defined in Azure App Service

Create an ASP.NET Core API in Visual Studio and Publish to Azure

In this post, we will create a Web Api using ASP.NET Core. We will create a basic CRM API system that manages Customers. The steps we will go through are: Create an ASP.NET Core Project in Visual Studio Get Customers Add a Model Publish to Azure Azure Portal Kudu Let’s get started. Create an ASP.NET Core Project in Visual Studio Open Visual Studio and create a new ASP.NET Core Web … Continue reading Create an ASP.NET Core API in Visual Studio and Publish to Azure

How to Change the Port in an ASP.NET Core Web API

To change the port in an ASP.NET Web API, under Properties go to the launchSettings.json file. In this case, let’s change the IIS default SSL port. Here it is 44354: If we run this before changing it by pressing F5, we see the page opens to port 44354: Let’s change it to port 44336: On rerunning our Web API, we see our port has been updated:  

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#

Creating an ASP.NET Core 3.1 Visual Studio Project with Sample

In this post, we will install an ASP.NET Core 3.1 Project in Visual Studio. This will also install the Weather sample. To do this, first open Visual Studio, create a new project: Search for ASP.NET Core Web Application: Enter a name, e.g. Carl.Weather.API and click Create: Select ASP.NET Core 3.1 and API and click Create: We see the project created: Press F5 to run. We see the weather forecast sample … Continue reading Creating an ASP.NET Core 3.1 Visual Studio Project with Sample

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

How to Create a Web API using 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 How to Create a Web API using ASP.NET

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