Microsoft Chat Bot


Introduction

Recent trends show that chatbots are essential everywhere, whether it’s an entertainment, medical, or knowledge-based website. Since this is an emerging technology, developers all around the world will be wanting to know more about this, specifically, what is happening in the background of chat bot applications. In this article we are developing the simple chatbot application using ASP.Net Core 3.1 with Core Bot Template.

Note : We have published the detail description of Chatbot conversational AI as a free E-book last week ( March 19 / 2021 ). We have added the link of the e book in the reference section please read before dive into this article.

Bot Framework

The Bot Framework have a capability to build a highly standard and rich enterprise conversational AI experience to the customers or end users. Also Bot Framework is a highly branded virtual assistant development framework or chatbot development framework by Microsoft. So we can build a chat bot with all kind of AI feature like Cognitive Services, QnA Maker, Luis, etc. There are many confusion on which situation we should use all this AI features in a chatbot development. So going forward we will understand in which situation this feature are more helpful for the chat bot conversational flow.

As of now by default Visual Studio do not contain any Bot Framework in template section. The SDK is available for Bot Framework template integration in Visual Studio, Please click here to download and install latest SDK for Bot framework in Visual Studio.

Azure Bot Service

First of all don’t be confused on Bot Framework and Azure Bot Service, As we discussed earlier Bot Framework SDK includes lot of open source SDK for building conversational AI.

Azure Bot Service is a platform provided by Microsoft to create and manage the chatbot application in Azure cloud environment using a single service or an endpoint call. There are many channels integrations available in Azure Bot Service for the interactive communication in chatbot application. The available channels are MS Teams, Slack, Messengers, etc.

Conversation Work flow

The below diagram is one of the example of chat bot conversational flow which means we can consider any type of flow as per our business requirement and this is one of the POC of conversational flow. The most of the Microsoft bot will use the same pattern for chatbot communication . Now we can dive into each segments that we have used in the following diagram.

Azure Subscription

A valid Azure subscription key is required for the creation of any of the services in the Azure portal. We can create an Azure subscription in multiple ways, either a free or paid service.

Please click here to create free Azure subscription -> Azure Free Subscription

Active Directory

There are many world-wide users communicating with the chatbot application, sometimes this will create a security attack and it create major problems in all the applications not only in chatbot. The AD or Active Directory is an enterprise identity service provides single sign-on ( SSO ) and multi-factor authentication to help protect your users from 99.9 percent of cybersecurity attacks. Also this is more helpful for managing an user in an organization with the help of azure environment.

Note: The security is more concern about all customers in world-wide and also expecting a highly availability so this we can achieve in azure environment without any single doubt.

App Registration

Within Azure Active Directory we can find out App registration, This will be more helpful to assign a large number of permission into the registered application inside the AD. I think everyone are familiar about Graph API, using this API we can give two levels of permissions ( Delegated & Application Level ) in a registered application in azure app registration pane. When you are developing a chatbot for internal organization or private communication inside the organization then those kind of scenarios we can handle through Graph API user level permission. Apart from that we can prevent the unauthorized user access and implement a role based ( Graph API can provide a complete user details in a AD) communication & permission in a chatbot application.

Note : As we have discussed earlier we need to create an Azure Bot Service in Azure environment , This will automatically register chatbot application in an App registration section included Bot channel registration. Please check our previous article for Web App Bot Creation in Azure.

Core Bot Template

We are using VS 2019 and Installed Bot Framework SDK V4 in our system environment. As you can see this chatbot application developing top of .Net Core 3.1 using C# with all AI features. By default it will provide LUIS ( Language Understanding Intelligent Service) code in the Core Bot template.

Visual Studio 2019 -> Bot Template

Create Web App Bot

Once after creation of Core Bot Template then we can host the application in azure environment with the help of Azure Bot Service. Please check our previous article for Web App Bot Creation in Azure.

After the creation of Web App Bot we can host our chatbot application in Azure environment using Visual Studio publish option. The successful deployment will give you the following result in “Test in Web Chat”. Just click on “Test in Web Chat” menu pane to open web chat channel for the chatbot testing.

Channel Configuration

Channel is nothing but it’s like a bridge to communicate between user and the bot application !!

As per the definition of Microsoft Docs :

“The Bot Service provides protocols and API’s through which you can connect your Bot to the services where your customers are. A channel represents the service you wish to reach your users on, such as Skype, Microsoft Teams or Facebook.”

These are the current available channels in Azure Bot Service.

Channel Configuration

We have already learned about how to configure slack channel in Azure Bot Service Slack Channel Configuration. Now we can learn the most popular “MS Team” channel with in simple steps.

First click on the Channels menu pain in our Bot service app and click on the “MS Team” icon.

Then select the respective radio button based on the business requirement and click on save.

Within a second MS Team channel configured in our Azure Bot Service with “Running” status.

Click on the MS Team icon and open the application in either browser or in MS Team application in your system. If the bot is not replaying with the welcome message then just try to enter one message.We are doing this for just testing the bot application in ms team channel.

Note : The best way to host the ms team channel application in an organization level is you need to create a bot app in app studio editor part of ms team application.

OUTPUT

Middleware

In Asp.Net Core, Middleware is software that is assembled into an app pipeline to handle requests and responses. So here we are registering all the chatbot related services like Storage, IBot, User State, Conversation State and other services as well.

The below example is state that “IBot” is inherited to “DialogAndWelcomeBot” and again this internally inherited into “ActivityHandler” and many more , we need to resolve this dependency using the middleware registration. The Ibot is the initial triggering point of chatbot application.

Example :

services.AddTransient<IBot, DialogAndWelcomeBot<MainDialog>>();

Storage

Managing the state is the vital role of communication in all kind of application not only chatbot, So how we can store the state in chatbot application, It’s pretty simple because Bot framework is provided by default package libraries for storing the state in Azure or InMemory.The Inmemory storage is basically using for testing purpose so when you are working on production then better to go with highly recommended Azure Cosmos Db. Why it’s highly recommended because Azure Cosmos Db have millisecond response times, and automatic and instant scalability, guarantee speed at any scale. Also highly available with enterprise-grade security. These are more important when you are deploying the chatbot applications for world wide usage. We can also use Azure Table Storage for the state management.

In Memory :

 // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.)
 services.AddSingleton<IStorage, MemoryStorage>();

Cosmos Db :

services.AddSingleton<IStorage>(c => new CosmosDbPartitionedStorage(new CosmosDbPartitionedStorageOptions()
            {
                AuthKey = Configuration["CosmosAuthenticationKey"],
                ContainerId = Configuration["ConfigCollectionName"],
                DatabaseId = Configuration["CosmosDbName"],
                CosmosDbEndpoint = Configuration["CosmosEndpoint"],

            }));

QnA Maker

QnA Maker is a prebuilt AI by Microsoft, It provide a Knowledge Base with Question and Answer Pairs. In chatbot application we can consider QnA maker as a database or a Knowledgebase to answer all kind of questions that we have already added in the QnA Maker Knowledgebase. These are predefined questions & answers adding by users themselves.

For Eg, In an organization if you have multiple department and you want to assure that the selected department ( UI menu selection for asking respective question) answers are properly getting as response through chatbot. These scenario we can achieve in many ways, One is we need to maintain multiple Knowledgebase in QnA Maker for each departments. Achieve this scenario we required LUIS for intent ( like category ) identification or department identification. Here intent is considered as department and inside the intent we can add utterances or questions for the department identification. Based on the intent we can deviate the respective Knowledgebase call in Qna Maker. another way to achieve this scenario is Luis dispatcher so please refer the E-book in reference section.

Language Understanding Intelligent Service ( LUIS )

LUIS is a prebuilt AI by Microsoft, Why we are using LUIS in a chatbot application that we have discussed in QnA maker section. Luis will identify the department or intent if organization have multiple department scenario in an application, this will give a clear picture at the end for which knowledgebase need to be connect inside the Qna maker. Here intent we can consider as department and inside the intent we can add utterances or questions for the department identification. So please refer the E-book in reference section for more detail about LUIS.

QnA Maker With Empty Response

If Qna Maker didn’t answer the question asked by user in that we need to handle in a tricky way either we need to display generic messages like

“Sorry, We are unable to answer your question and could you please rephrase it”

Another way is connecting to Bing Search API, Google Search API, etc for un answered question from qna Maker but this is not a good practice for domain bot application for an organization.

Live Agent Connect / HandOff:

Sometimes user want to connect a human agent or live agent, These are our findings and implementation details.

  1. As per the github documentation from Microsoft, I understood that there is an experimental package available for handoff in C# code ( Microsoft Handoff library ). As of now this library is not recommended for production use and please check this experimental docs reference for more info and below comments in the github account :

The samples in this folder should not be used in a production environment. They are not supported and the team is not implying a given approach used in these samples will be integrated into a future version of the Bot Framework SDK. Instead, we want to provide a way to engage on topics that can help guide our roadmap for future work.

  1. This is the best open source code for live agent ( handoff library ) that I found from github. The author of the code is an approved microsoft open source contributor and he has developed an agent hub routing + multiple channel connectivity in the bot. This will handle multiple user request to an agent with the help of agent hub. The agent can open a communication channel for user connectivity. You will get a better understanding once you go through the documents.
  2. This is the one I have implemented reference, This will be a simple redirection to an agent from an user with his comments or issues through microsoft team channel group. I have implemented one way communication but at least you can inform to the group ( created for agent team ) for user issues with his account details in the channel in ms team. So any of the agent in the team can personally contact him through ms team account and resolve the issues.

Reference

Summary

From this article we have learned the important background process and implementation of chatbot application.

My First E-Book


My first book ( E-Book ) !!.

The Implementation & handling of multiple Microsoft chatbot modules is based on my work experience of rigorous 8 years on the Microsoft Stack included chatbots. During my IT days, I am passionately involved and dedicated my good time on this subject matter and it happened to be my first book ( E-Book ) in C# Corner .

How a person feel gratitude when there is so many people responsible for greatfulness. Respected Mr.Praveen, Mr.Mahesh and C# Corner Team for laying out a wonderful platform for the technical contributions, I am indebted to my most respected mentor Mr.Tadit dash for his immense contributions.

Unquestionably there is a chronicle behind every successful achievements, Two years back I was planning to write a book related to automation in C# Corner community but that plan was dropped due to the suggestion from dear friend Priyaranjan, as my functional area is based on latest technologies and must not shift to automation, his suggestions was very valid. The reason I planned to write a book in latest technologies, but it got delayed due to covid pandemic and obviously some of the office workloads.

Also many of the famous publishers reached out me to write books in upcoming technologies and I discussed several topics with most admired Mr.Gaurav but at the end I had a different thought in my mind, Nine-Tenths of wisdom is being wise in time so was need to publish the book completely free for the user and I remember seeking knowledge is like opening doors and I know doors everywhere.

Thank you all of my friends & family who has supported my ups and downs in my life.

E-Book : THE IMPLEMENTATION & HANDLING OF MULTIPLE MICROSOFT CHATBOT MODULES

My 5th C-SharpCorner MVP Award


Finally I have received my 5th consecutive C-SharpCorner mvp award 🏆( 2015 to 2020 ). Always my sincere gratitude to taditdash who has introduced me to this wonderful community in 2014 and Thank you praveen sir , dinesh ir, Atul Gupta sir , mahesh sir for your greatest support. Thank you all my readers and supporters 🙏 Stay Safe and Stay Home 🏠. #mvp #csharpcorner #award

MVP Award 2020

Cognitive Services : Creation of Language Understanding Intelligent Service or LUIS


Introduction

One of the important api in Cognitive Services is Language Understanding Intelligent Service or LUIS and it is a natural language processing service that enable us to understand human language in our own application, website, chatbot, IoT device, etc. Once configure , train and publish your LUIS model, then the application can easily receive user input in natural language and take an appropriate action based on our intent,utterances,entity configuration in LUIS Model.
We can easily create LUIS model with the help of LUIS account and for this we require LUIS “Authoring resource” in Azure. So first of all, we need to create a LUIS API in Azure account using valid subscription key.

You can also refer the following articles on Cognitive Service.

Prerequisites

  1. Subscription key ( Azure Portal ) or Trail Subscription Key
  2. Visual Studio 2015 or 2017 0r 2019

Create LUIS in Azure

Step 1 : Click on “+” icon -> go to “AI + Machine Learning” -> Click on “See all”.

Step 2 : Go to Cognitive Services and click on “See more”

Step 3 : Click on “Language Understanding”

Step 3 : The following screen will appear once you click on “Create” button in “Language Understanding”

  1. Subscription : We can select our Azure subscription for Language Understanding.
  2. Resource group : We can create a new resource group or choose from an existing one ( We select our existing resource group as “luis-test” ).
  3. Authoring location : The best thing is we can choose a location closest to our customer needs.
  4. Authoring pricing tier : We can choose the appropriate pricing tier as per our needs.
  5. Prediction location : The best thing is we can choose a location closest to our customer needs.
  6. Prediction pricing tier : As of now there are two pricing tier available “FO” & “SO” and obviously “FO” is the free one and better we can choose the appropriate pricing tier as per our needs.

7. Click on the “Review + Create” button and wait for the build success.

8. Once the build is succeeded, then click on the “Dashboard” and we can see “luis-cog-testing” is created in the All resources list . LUIS is ready for use !!.

Create Luis Application

We have already created the LUIS authoring resource in azure and now we can easily create LUIS model in Luis account. So go to LUIS account and create a new LUIS App.

  1. Name : Name of the luis application.
  2. Culture : The current culture or language going to use in Luis application.
  3. Description : A short description of our application.
  4. Authoring resource : The resource that we have created in azure.
  5. Prediction resource : The resource that we have created in azure.

Output :

The app is successfully created in LUIS and by default it will contain one “Intent” called as “None”. We will discuss in details of intent , utterances , entity in the upcoming articles.

Reference

Summary

From this article we have learned how to create LUIS model with the help of LUIS account and LUIS “Authoring resource” in Azure . I hope this article is useful for all beginners.

C-SharpCorner MVP Award 2020 🏆🏆🏆🏆🏆


The 5th Consecutive year I am getting MVP Award from C-SharpCorner Technical Community. As a IT professional we are learning new technologies in entire life. Continue your passion and one day it will help to achieve your goal. Thank you all for your support.

C# Corner MVP's 2020

C# Corner MVP’s 2020

Congrats to all other MVP’s : C# Corner Q1, 2020 MVPs Announced

Get started with Blazor Apps


Introduction

We have developed many Single Page Application using Angular,  Aurelia, React, etc. Finally the microsoft has introduced Blazor Apps and It is a programming framework to build client side rich web application with dotnet using c#. What ? Is it possible to create a Single Page Application using C# without using JavaScript ? Yes we can create a rich interactive User Interface ( UIs ) using C# instead of JavaScript and also the client and server code logic has written in the app using .Net. The Innovations are the major concerns of every era, So as a dotnet developer we can develop a Single Page Application ( SPA ) using Microsoft C#.

Blazor app have five different editions and two are now available in the Visual Studio and three editions are in a planing stage.

  • Blazor WebAssembly
  • Blazor Server
  • Blazor Progressive Web Apps (PWAs)
  • Blazor Hybrid
  • Blazor Native

The following are the currently available Blazor apps.

Blazor WebAssembly

Blazor WebAssembly is a single-page app framework for building interactive client-side web apps with .NET ( dotnet ). Blazor is running client-side in the browser on WebAssembly and the client side code has been written in C# instead of using javascript. So the .Net code is running inside the browser with the help of Webassembly(abbreviated wasm). Yes , It will work all the modern web browsers and including mobile browsers. There’s no .NET server-side dependency but the app is fully functional  after downloading the .Net runtime to the client. This will create a client-side dependency and Serverless deployment scenarios are possible because ASP.NET Core web server doesn’t required to host the app.

As per the Microsoft information “Blazor WebAssembly” is still in preview and expect to live by may 2020. So it is clear that Blazor WebAssembly is not ready for the production use and currently in a development stage.  If you’re looking for a production solution, then you can choose “Blazor Server” and it is recommended by Microsoft.

Blazor Server

Blazor Server provides support for hosting Razor components on the server in an ASP.NET Core app that means Blazor can run your client logic on the server.  The UI updates, event handling, and JavaScript calls are handled over with the help of “SignalR” ( a real-time messaging framework. ) connection. The download size is smaller than Blazor Server Comparing to Blazor WebAssembly app because those are handling in server side and the app loads much faster. Serverless deployment is not possible because an ASP.NET Core server is required to serve the app.

As daniel mentioned in the document “We have expect to have official previews of support for Blazor PWAs and Blazor Hybrid apps using Electron in the .NET 5 time frame (Nov 2020). There isn’t a road map for Blazor Native support yet. The following are the Blazor App planning editions”.

Blazor PWAs ( Progressive Web Apps )

Blazor PWAs ( Progressive Web Apps  ) are web apps that support the latest web standards to provide a more native-like experience. It will work offline and online scenarios and support push notifications, OS integrations, etc.

Blazor Hybrid

Native .Net readers to Electron and Blazor Hybrid apps don’t run on WebAssembly but instead uses a native .NET runtime like .NET Core or Xamarin. It will work offline or online scenarios.

Blazor Native

Same programming model but rendering non-HTML UI.

Note :  The application is tested in .NET Core 3.1 SDK & Visual Studio 2019 16.4 version and all the steps depend on the respective versions.

Prerequisites

  1. Install Visual Studio 2019 16.4 or later with the ASP.NET and web development workload.
  2. Install the .NET Core 3.1 SDK.

1.  Create a new project in Visual Studio 2019 ( version 16.4 ) and It lists the available project templates. So we have to  choose “Blazor App” template for development.

Create a new project

Create a new project

2. Configure new project name, solution name and location in our system.

Configure new project

3.  Based on the selected Blazor template ( Step 1 ) It will display the two available Blazor app in Visual Studio. So we have selected “Blazor Server App” from the list.

Output

We can run the application and see the first output of our Blazor Server App.

Reference

Summary

From this article we have learned the basics of microsoft Blazor Apps With Visual Studio 2019. I hope this article is useful for all the Blazor ASP.NET Core beginners.

C# Corner One Million Readers Club


Thank you all my readers !!! Thanks for the gift Atul Gupta , Praveen Kumar and C# corner team. #MVP #CsharpCorner

Web API documentation using Swagger & ASP.NET Core With Visual Studio 2019


Introduction

There are more challenges we are facing for consuming a Web API because it contains  various methods such as GET,POST,PUT,DELETE. All these methods  contain various types of parameters like model,string,int,etc. Exactly we don’t know what property we need to pass in the model parameter and what are the relevant ones. These are the major challenges for a developer and so we need a proper documentation to solve this problem. That’s why we choose Swagger also known as OpenAPI and It  will provide all such benefits like interactive documentation, client SDK generation, and API discoverability. In this article we are explaining a lit bit basic configurations of Swagger in ASP.NET Core application. We can add more additional features on the Web API using swagger for that just read the reference document that we have mentioned in the Reference section.

We have tested the swagger documentation application in the latest VS 2019. So please check the following steps to kick start the initial process of installation.

1) Open Visual Studio 2019 and Click on “Create a new project”


2) Click on ASP.NET Core Web Application


3) Provision your new project and give the appropriate name and the location to be saved.


4) Choose API and Click on the Create button on the right side.


5) Open “Tools -> Nuget Package Manager -> Manage Nuget Packages for Solution…” and click on Browse tab and search “Swashbuckle.AspNetCore” in the search bar and install it.

Model

We are going to create a Employee model for the demo purpose.

namespace SwaggerDocumentation.Model
{
    public class Employee
    {

        public int id { get; set; }
		
		public string Name { get; set; }
		
		public string Adress { get; set; }

		public string Department { get; set; }

    }
}

API Version Separation

In future if we are planning to release multiple versions of API, then, for the better readability purpose we can create a version folder for the API creation. This will help us to differentiate multiple versions in the API side and Swagger documentation. In the following screenshot we have created two folders one is “v1” ( Version 1 ) and another one is “v2” ( Version 2 ). obviously v2 will contain the latest version comparing to v1.

API Controller

We have created “EmployeeController” as the API controller in our application. Here we can see at the route level api path is set as “api/v1/[controller]” because when you hit the swagger it will first check the controller level then what will happen it will take two identical controller name as “Employee”. This will create ambiguous issue in the http request controller level, for that reason we have added two different request path for both versions v1 & v2.

using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using SwaggerDocumentation.Model;

namespace SwaggerDocumentation.Controllers.v1
{
    [Route("api/v1/[controller]")]
    [ApiController]
    public class EmployeeController : ControllerBase
    {
        // GET: api/v1/Employee
        [HttpGet]
        public List<Employee> EmployeesDetails()
        {
            List<Employee> employees = new List<Employee>
            {
               new Employee
               {
                   Name = "Rajeesh",
                   Department = "Development",
                   Adress = "Menoth Parambil"
               },

               new Employee
               {
                   Name = "Arokia",
                   Department = "R/D",
                   Adress = "Trichy Central"
               },

               new Employee
               {
                   Name = "Vijay",
                   Department = "Cloud",
                   Adress = "MP Gowliyar"
               },

            };

            return employees;
        }

        // GET: api/v1/Employee/5
        [HttpGet("{id}", Name = "Get")]
        public Employee EmployeeDetailsInformation(int id)
        {
            List<Employee> employees = new List<Employee>
            {
               new Employee
               {
                   id = 1,
                   Name = "Rajeesh",
                   Department = "Development",
                   Adress = "Menoth Parambil"
               },

               new Employee
               {
                   id = 2,
                   Name = "Arokia",
                   Department = "R/D",
                   Adress = "Trichy Central"
               },

               new Employee
               {
                   id = 3,
                   Name = "Vijay",
                   Department = "Cloud",
                   Adress = "MP Gowliyar"
               },

            };

            return employees.Find(x => x.id == id);
        }

        // POST: api/v1/Employee
        [HttpPost]
        [ApiExplorerSettings(GroupName = "v1")]
        public void Post([FromBody] string value)
        {
        }

        // PUT: api/v1/Employee/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE: api/v1/ApiWithActions/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}

IControllerModelConvention

In the ASP.NET Core MVC we have application model and it will define convention abstractions that provide a simpler way to customize the behavior of the models without overriding the entire model. In simpler way we are modifying our app to follow different conventions from the default MVC behavior. The following method is clearly describing that it will take the last name of the “namespace” and it consider as the group name of the API Version. So in this case we can easily separate out versions when we  maintain multiple version of API’s in the application. The “GroupName”  can be declared as globally and locally, but in multiple API version case we can go with global scenario.

public class ApiExplorerVersionConvention : IControllerModelConvention
    {
        public void Apply(ControllerModel controller)
        {
            var controllerNamespace = controller.ControllerType.Namespace; // e.g. "Controllers.v1"
            var apiVersion = controllerNamespace.Split('.').Last().ToLower();

            controller.ApiExplorer.GroupName = apiVersion;
        }
    }

The following way we can declare group name  locally but in this scenario you need to add the following decorator for each API method .

 // POST: api/v1/Employee
        [HttpPost]
        [ApiExplorerSettings(GroupName = "v1")]
        public void Post([FromBody] string value)
        {
        }

Middleware

We need to inject swagger service in the ASP.NET Core application using the middleware in startup class. Then only we can access the entire swagger service in our application.

ConfigureServices ( Inside the Startup.cs )

ConfigureServices method gets called by the runtime so we can use this method to register the services to the container  in the application. First of all we need to add “ApiExplorerVersionConvention” convention in the MVC service like the following way.

services.AddMvc(x => x.Conventions.Add(new ApiExplorerVersionConvention()));

The following code will register the swagger in our Application. There are many properties we use in the following code like “v1” & “v2” consider as GroupName , Title is displayed as “Swagger Documentation” and “Version 1.0” & “Version 2.0” is the version separation.

// Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info { Title = "Swagger Documentation", Version = "Version 1.0" });
                c.SwaggerDoc("v2", new Info { Title = "Swagger Documentation", Version = "Version 2.0" });
            });

Configure ( Inside the Startup.cs )

Configure method gets called by the runtime and use this method to configure the HTTP request pipeline. We are going to enable the generated Swagger as a JSON endpoint in the middleware and it will serve to the request.

app.UseSwagger();

The swagger UI and json endpoint we can mention in the following way.

app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                c.SwaggerEndpoint("/swagger/v2/swagger.json", "My API V2");
            });

launchSettings.json

In launchSettings.json we can setup swagger as the launch URL. This is not mandatory to give because for the demo purpose we have given launch URL as swagger. Otherwise In middleware we have SwaggerEndpoint  “/swagger/v1/swagger.json” so you can enter in the browser like “http://localhost:44392/api/swagger&#8221;.

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": {
      "applicationUrl": "http://localhost:62460",
      "sslPort": 44392
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "SwaggerDocumentation": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

 

Output

Reference

Summary

From this article we have learned the Web API documentation using Swagger & ASP.NET Core With Visual Studio 2019. I hope this article is useful for all the ASP.NET Web API beginners.

C# Corner Featured Community Leader 2019


 

Thanks a lot Mahesh Chand Sir making this wonder full video. Thank you for all the support C# Corner Team.

C-SharpCorner MVP Award 2019 🏆🏆🏆🏆


Everyday is a new beginning here in our C# Corner Community.We learn new things day by day and share the knowledge to the entire world. I as an individual had improved a lot in my technical aspects from this community. And thanks a lot for awarding me MVP for the fourth consecutive year. It is a great privilege to receive this award from the veterans. On this context I would like to thank my family and friends for staying with me during my ups and downs.

Thank you all !!

Congrats to all other MVP’s :  Q1 C# Corner MVP’s 2019

%d bloggers like this: