Tags
Language
Tags
May 2025
Su Mo Tu We Th Fr Sa
27 28 29 30 1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
    Attention❗ To save your time, in order to download anything on this site, you must be registered 👉 HERE. If you do not have a registration yet, it is better to do it right away. ✌

    ( • )( • ) ( ͡⚆ ͜ʖ ͡⚆ ) (‿ˠ‿)
    SpicyMags.xyz

    Minimal Webapi With Asp.Net Core (Visual Studio 2022)

    Posted By: ELK1nG
    Minimal Webapi With Asp.Net Core (Visual Studio 2022)

    Minimal Webapi With Asp.Net Core (Visual Studio 2022)
    Published 9/2022
    MP4 | Video: h264, 1280x720 | Audio: AAC, 44.1 KHz
    Language: English | Size: 803.69 MB | Duration: 2h 25m

    beginner to advanced course for professionals and college students

    What you'll learn
    Minimal WebApi of C# ASPNET Core (Visual Studio 2022 and later)
    GET, POST, PUT and DELETE various types covered
    Calling from desktop C++ App, C# Console, C# WPF Apps
    Use of HttpRepl
    Parameter Binding to QueryString, Header and Custom Bindings
    FileUpload with WebApi
    JWT Server and Client Side Authentication
    Basic Authentication
    Social Media based Authentication (Google)
    Requirements
    Some knowledge of C#
    Some knowledge of Entity Framework C#
    Description
    This course is a brief course that teaches minimal web-api of ASP.NET Core. Explanation is in a simple language. Downloads have been provided with almost every chapter. Tutorials have been kept brief and to-the-point. Audio is crystal clear.Getting Started with Web ApiThis tutorial starts with a beginner's introduction to the concept of web api. After that we create a basic structure of a project that will help us learn about various types of web api - which will be serially covered in the next coming tutorials.Minimal GET WebApi with No ParametersIn this tutorial we shall add a web api that allows us to get all the records of a table. Please do note, however, that such a query is never done in a real project - it is invariably qualified with some paramaters that return a lesser number of records.Minimal GET WebApi with a Parameter of Numeric TypeIn the previous tutorial we learned how to write a web api that accepts no parameters. We executed it to return all the records of a table. In this tutorial we shall add another web api that accepts a parameter and returns data on the basis of that parameter.Minimal GET WebApi to Find a Record by IdIn this tutorial we shall add a web api of GET type that takes an ID as a parameter and returns a record for that parameter.Using Postman to Run WebApiPostman is a software that can be used to easily and conveniently run and execute web api. It can be installed as a desktop application. The software offers a lot of functionality, but we shall be using a small part of that - relevant to just our web api needs.Minimal POST WebApi for Creating a new RecordA web api of the POST type is used to create a new record. For example, if we have to create a new record of a doctor, then we have to use a POST api to send the relevant fields for creating a record.Minimal PUT WebApi for Updating a RecordAn Http PUT request is used to update an existing record. For this, a client has to send the unique id of the record along with the entire updated record. Partial updates are not done with a PUT type of Web Api. Partial updates are, rather, supported by an HTTP PATCH request. But that is not the topic of this tutorial. Today we shall focus on the Http Put type of Web Api.Minimal DELETE WebApi for Deleting a RecordAn HTTP DELETE request is used for deleting a record. The Server sends a 200 OK response on successful deletion alongwith the item that was deleted. Alternatively, it can send 204 No Content if the deleted item is, or cannot be included in the response. Let us see the implementation in this tutorial!Over-Posting in WebApi and a Solution with Data Transfer ObjectWe have been working with a model class consisting of three properties - id, Name and Fees. All the three properties have participated and have been exposed in json communication through every Web Api that we have discussed and written in the past tutorials of this chapter. This is called over-posting. But what if there were a property such as an email address that we didn't want exposed? This tutorial presents a solution through the concept of a Data Transfer Object.Preventing Over-Posting of a Collection in a WebApiIf an API has to return a collection of records, and if we do not want entire objects transmitted, then we can use a Data Transfer Object to return a small subset of properties, just-the-required subset. For a primer on over-posting, please refer the previous tutorial "Over-Posting in WebApi and a Solution with Data Transfer Object".DTO Object as Argument and Return in a WebApiThis tutorial explains how to modify a POST type of WebApi so that it doesn't over-post data. A POST WebApi receives a data object as a parameter, and then adds it to a database, and finally it returns an HTTP 201 Created response alongwith the json for the newly added object. We have already covered this in one of the previous tutorials and for a primer on over-posting, please refer a previous tutorial "Over-Posting in WebApi and a Solution with Data Transfer Object".Calling a GET WebApi from a C++ WinRT AppThis tutorial explains how a GET web api can be called from a C++ WinRT application. I have chosen WinRT type because it contains a lot many pre-written functions that simplify internet access and json parsing. I won't be able to explain the details of a WinRT setup, so I have already created a WinRT console application that connects to our web api, and then obtains a string from the application, and then parses the json contained in that string. The c++ project has been provided in the downloads attached to this course.Calling a POST WebApi from a C++ WinRT AppThis tutorial explains how a POST web api can be called from a C++ WinRT application. I have  created a WinRT console application that connects to, and posts a json string to a POST web api, and then obtains a string response from the application, and then parses the json contained in that string. The c++ project is available in your downloads.OpenAPI and Swagger for Web API DocumentationSwagger makes it easy to document the various Web Api exposed by your project. The summary of your API is maintained in a json based file called openapi.json. This document is the main document. It is an intermediate document that is used to create a web page called SwaggerUI - which shows all your web api in a colorful, human readable interface. Each web api can be immediately run and tested. It turns out that SwaggerUI is much more easier as compared to the Postman software.Configuring and Using Swagger to Run WebApiLet us now configure our WebApi project to add support for SwaggerUI. As we told earlier, SwaggerUI is provided by both SwashBuckle and NSwag. We can use either of the two - and I shall be using SwashBuckle.Call a GET Web API From a C# WPF ApplicationIn this tutorial we shall learn how to call the various types of WebApi from a C# WPF application. I have already created a WPF application that obtains a list of records from our web api project and renders them in a grid. This is a GET web api request that queries a collection of records. The same WPF window has a form for creating a new record - and this is done with a call to the POST web api. When a user clicks a record on the WPF window, a dialog pops up that allows the user to update the record. This will be a call to the PUT Web Api. The same dialog has a delete button that makes a call to the DELETE Web Api.Call a POST Web API From a C# WPF ApplicationThis tutorial continues from the previous tutorial. We have discussed most of the parts there. So please go through the previous tutorial for a continuity. Now we shall call a POST WebApi from our Wpf Application, and create a new record.Call a PUT and DELETE Web API From a C# WPF ApplicationAs you must have already seen in the previous tutorials, we have a WPF application that obtains a list of records from our ASPNET Core web api application, and shows them in a WPF datagrid. When a row of the datagrid is clicked, a dialog pops-up that shows a form for editing the record. The save button for this form is wired to a click event handler that makes a PUT call to a web api and updates the record. A delete button on the same form causes a call to a DELETE web api.Introduction to HttpRepl for Testing Web ApiHttp Repl is a command-line tool for testing web api. This tool targets the ASP.NET Core environment. Let's have a look at a brief introduction to this tool. We will also learn how to activate it in visual studio. And in the coming tutorials we shall use it to make a few web api calls.Connecting HttpRepl to a Web Api EndpointBefore we can execute and test any web api, we have to establish a connection between httprepl and our web server. If you are following this chapter, then you must have observed that each of our route templates starts with the segment "doctor". Technically, it is called an end-point. The objective of this tutorial is to learn how to connect to a server, and how to get a list of available endpoints, and how to finally navigate to a specific endpoint - which is "doctor" in our case. In the coming tutorials we shall make calls to the various types of web api that we have already added to our web api project.Testing a GET Web Api with HttpReplNow its time to use httprepl for testing our web api. To begin with, we shall test a GET api. I shall assume that your httprepl is installed and ready. If things appear difficult, then you may have to go through the previous two tutorials for learning the basics of httprepl.Testing a POST Web Api with HttpReplIn this tutorial we shall test a POST Web Api - and create a new record. So we shall have to first establish a connection between httprepl and our web server, and, then we will have to post the json for the new record that we have to create on the server. Let's see how!Using a static class for Route Handlers in a Minimal WebApiSo far, we have been writing all our minimal web api in the program.cs file. But this can become un-manageable and un-readable in a full blown project. We need a scheme for organizing our web api so that they can stay in a class of their own, inside a file of their own. We can even have a possibility of multiple classes - with each class containing all the related web api - those of a doctor in one file, whereas those of a patient in another. In this tutorial we have a brief look at the various possibilities, and finally I show an implementation of the scheme that I personally prefer.[FromQuery] Parameter Binding of a QueryString VariableWe have been obtaining our web api parameters from route templates. A route is not the only source of parameters - in fact the parameters can be obtained from a query string, header values and from the body of the request also. In this tutorial we examine how to obtain the parameters from a query string variable, and how to set the parameter as optional.[FromHeader] Parameter Binding of a Request HeaderParameters of a web api can be obtained from the values in a request header also. For this an attribute called "FromHeader" is used to decorate a parameter, and it provides an easy access to the value contained in the header of that name. In this tutorial we shall learn how to bind a header to a web api parameter. For continuity please go through the previous tutorial where we saw how to bind a query string variable to a parameter.Special Types of Implicit Parameter BindingsASP.NET Core provides certain "special" parameters that are always available to an api handler. These parameters are "utility" parameters like HttpContext, HttpRequest, HttpResponse, CancellationToken and ClaimsPrincipal. They do not need any attribute decorations like those for the query-string, header, body and route segments.Customized Binding of API ParametersConsider a web api that extracts parameters x, y and z from its query string and then uses these values to construct a Point object, say for example, by passing these data to a constructor of the Point class. This program can be made more readable by passing a single string of a comma separated list of three numbers, and then have that string directly parsed into a Point object. This technique of customized binding is the subject matter of this tutorial.BindAsync for Customized Binding of WebApi ParametersBindAsync is a second method for custom binding of parameters. The first one - TryParse - is good for cases where the items are available in a single string - most ideally as in a query string, or a header value, or a route segment. However, if need a greater control over the binding process, then a more robust parameter such as the HttpContext is more suitable - and the BindAsync method does exactly that. It provides a signature that contains HttpContext as a parameter.File Upload with a WebApiIn this tutorial we examine how to write a web api that accepts an uploaded file and saves it to a server. We shall also present a C# console application that will post a file to that web api. Let's see how!Basic Authentication in WebApiBasic Authentication is not encourged by ASP.NET Core because login id and password are sent as plain text in the request header - it's vulnerable to XSRF also. So there are no readymade classes like we have for cookies based authentication. But what if your project still needs to allow basic authentication? Perhaps because your security requirements are not of extreme cutting-edge type? For that case we present a simple solution that helps you protect a web-api with basic authorization. It can be a lot safer with Basic Authentication if your communication is over https, and even better if XSRF measures are taken, which is beyond the scope of this tutorial.HandleAuthenticateAsync and Basic Authentication in WebApiThe recommended way of implementing a custom authentication scheme is by deriving a class from AuthenticationHandler and implementing the HandleAuthenticateAsync function. This makes the code systematic because the authentication and header parsing code now moves to a dedicated class. This approach also allows us to include multiple authentication schemes in the same project - for example you might want one web api to be authorized through basic authentication, and another one through a JWT based authentication, and yet your razor pages through a cookie based authentication. In this tutorial we implement the basic authentication scheme.JWT Authentication in WebApiJWT stands for JSON Web Token. In its simplest form, JWT authentication is a two step process. First a client obtains a JWT token from the server. This token is signed with a secure key and encrypted with a standard encryption algorithm. It has an expiry date, and it contains a list of claims such as the user-id, user-role, his email, etc., The client obtains authorization to a web api by sending this token in an authorization header. In this tutorial we shall see a server side implementation of the code for generating a JWT token, and of protecting a web api.C# Console App Connectivity for Basic and JWT AuthenticationIn this tutorial we present a C# console application that connects to the web api that we have done in the previous tutorial. This app will first obtain a JWT Token by sending it's login credentials in a basic authorization header, and then it will use that token in a bearer header to obtain authorization to the second api protected by JWT Authorization. Please go through the previous turorial where we have explained both the web apis.Creating a Google OAuth App for AuthenticationSocial media based authentication requires us to create an oauth app on a social media platform such as google, facebook, twitter, github. This app provides us a client id and a client secret key for use in various classes that provide social media integration. In this tutorial we have a walkthrough for creating an oauth app on the google cloud console. Steps for other social media are similar - so you can take them as an exercise.Social Media Authentication in WebApiWebApi can be protected through social media authentication also. The first step is to obtain a client id and a client secret by creating an app on a social media platform. Then these values are used to configure authentication services for that platform. In this tutorial we present the sequence of steps required to gain authorization to a web api protected by google authentication.

    Overview

    Section 1: Getting Started with Web Api

    Lecture 1 Getting Started with Web Api

    Section 2: Minimal GET WebApi with No Parameters

    Lecture 2 Minimal GET WebApi with No Parameters

    Section 3: Minimal GET WebApi with Parameters

    Lecture 3 Minimal GET WebApi with Parameters

    Section 4: Minimal GET WebApi FindByID

    Lecture 4 Minimal GET WebApi FindByID

    Section 5: Using Postman to Run WebApi

    Lecture 5 Using Postman to Run WebApi

    Section 6: Minimal POST WebApi

    Lecture 6 Minimal POST WebApi

    Section 7: Minimal PUT WebApi

    Lecture 7 Minimal PUT WebApi

    Section 8: Minimal DELETE WebApi

    Lecture 8 Minimal DELETE WebApi

    Section 9: Over-posting and Data Transfer Objects

    Lecture 9 Over-posting and Data Transfer Objects

    Section 10: Preventing Over-Posting of a Collection

    Lecture 10 Preventing Over-Posting of a Collection

    Section 11: DTO Object as Argument and Return

    Lecture 11 DTO Object as Argument and Return

    Section 12: Calling a GET WebApi from a C++ WinRT App

    Lecture 12 Calling a GET WebApi from a C++ WinRT App

    Section 13: Calling a POST WebApi from a C++ WinRT App

    Lecture 13 Calling a POST WebApi from a C++ WinRT App

    Section 14: OpenAPI and Swagger for Web API Documentation

    Lecture 14 OpenAPI and Swagger for Web API Documentation

    Section 15: Configuring and Using Swagger to Run WebApi

    Lecture 15 Configuring and Using Swagger to Run WebApi

    Section 16: Call a GET ALL Web API From a WPF App

    Lecture 16 Call a GET ALL Web API From a WPF App

    Section 17: Call a POST Web API From a WPF App

    Lecture 17 Call a POST Web API From a WPF App

    Section 18: Call a PUT and DELETE Web API From a WPF App

    Lecture 18 Call a PUT and DELETE Web API From a WPF App

    Section 19: Introduction to HttpRepl for Testing Web Api

    Lecture 19 Introduction to HttpRepl for Testing Web Api

    Section 20: Connecting HttpRepl to a Web Api Endpoint

    Lecture 20 Connecting HttpRepl to a Web Api Endpoint

    Section 21: Testing a GET Web Api with HttpRepl

    Lecture 21 Testing a GET Web Api with HttpRepl

    Section 22: Testing a POST Web Api with HttpRepl

    Lecture 22 Testing a POST Web Api with HttpRepl

    Section 23: Using a static class for Route Handlers

    Lecture 23 Using a static class for Route Handlers

    Section 24: Parameter Binding of a QueryString Variable

    Lecture 24 Parameter Binding of a QueryString Variable

    Section 25: Parameter Binding of a Header Value

    Lecture 25 Parameter Binding of a Header Value

    Section 26: Special Types of Implicit Parameter Bindings

    Lecture 26 Special Types of Implicit Parameter Bindings

    Section 27: Customized Binding of API Parameters

    Lecture 27 Customized Binding of API Parameters

    Section 28: ValueTask and Task

    Lecture 28 ValueTask and Task

    Section 29: BindAsync for Custom Binding

    Lecture 29 BindAsync for Custom Binding

    Section 30: FileUpload with a WebApi

    Lecture 30 FileUpload with a WebApi

    Section 31: Basic Authentication in WebApi

    Lecture 31 Basic Authentication in WebApi

    Section 32: HandleAuthenticateAsync and Basic Authentication

    Lecture 32 HandleAuthenticateAsync and Basic Authentication

    Section 33: JWT Authentication in WebApi

    Lecture 33 JWT Authentication in WebApi

    Section 34: Client App for JWT Authentication

    Lecture 34 Client App for JWT Authentication

    Section 35: Creating a Google OAuth App for Authentication

    Lecture 35 Creating a Google OAuth App for Authentication

    Section 36: Social Media Authentication

    Lecture 36 Social Media Authentication

    Beginners and Students (language used is simple, crude)