Monday, October 22, 2018

Azure Blob Storage Tiers

Azure Blob Storage Tiers

Image result for azure

There are few points which you should remember while developing or managing Azure Storage pertinent to Tier for data access.


Azure Hot Storage  Tier ----> It uses for fast retrieval of data or lowest data retrieval cost and lowest data access cost though higher data storage cost involve.

Azure Cool Storage  Tier ---> Higher in data retrieval cost while lower in data storage cost.

Azure Archive Storage  Tier  ---> Highest data retrieval cost while Lowest data storage cost .


Kindly consider all above points while you are about to choose Storage Tier’s in Azure


Warm Regards

Sachin Kalia

Saturday, October 13, 2018

WINDOWS POWERSHELL COMMANDS

WINDOWS POWERSHELL COMMANDS

Open your power shell from command prompt as a administrator.

Point to remember : Declare any variable with $y in PowerShell


C:\WINDOWS\system32>$array ="India","Japan","Aus","US","UK"

C:\WINDOWS\system32> $array

It will list an array


PS C:\WINDOWS\system32> $array[2]

It gives value on index 2 , which is AUS in our case.


image

$array=("India","Asia"),("Japan","Asia"),("AUstralia","Australia"),("UK","EUROPE"),("US","North America”)

PS C:\WINDOWS\system32> $array

PS C:\WINDOWS\system32> $array[0][1]
Asia
PS C:\WINDOWS\system32> $array[1][1]
Asia
PS C:\WINDOWS\system32> $array[1][0]


======================================

Some mathematical commands show below:

PS C:\WINDOWS\system32> $y=get-service
PS C:\WINDOWS\system32> $y.count
292
PS C:\WINDOWS\system32> [math]::sqrt("9")
3
PS C:\WINDOWS\system32> $x="192.78788"
PS C:\WINDOWS\system32> [math]::round($x,2)
192.79








4. To update the value of an index in array as shown below:

PS C:\WINDOWS\system32> $array[1][0]="Singapore"
PS C:\WINDOWS\system32> $array[1][0]



5. To change the variable case in upper and lower use the following command


PS C:\WINDOWS\system32> $x="The quick brown fox jumps right over the lazy little dogs"
PS C:\WINDOWS\system32> $x.ToUpper()
THE QUICK BROWN FOX JUMPS RIGHT OVER THE LAZY LITTLE DOGS
PS C:\WINDOWS\system32> $x.TOLOWER()

Output
the quick brown fox jumps right over the lazy little dogs


6. To replace any word


PS C:\WINDOWS\system32> $x.replace("The","That")
That quick brown fox jumps right over the lazy little dogs



7. To Get complete service object in a variable

Declare any variable with $y in PowerShell

PS C:\WINDOWS\system32> $y=get-service
PS C:\WINDOWS\system32> $y.count
Output : 292

Wednesday, October 10, 2018

Azure Session in Noida,India

Conducted and Executed Azure session in Noida today Some Glimpse Conversation following topics

Image result for azure images

  • Azure
    ARM Portal (Azure Resource Manager)
    Azure Service Model
    ARM Portal Deep Dive
    Platform As A Service(PaaS)
    Hosting .Net WEBAPI Application
    Application Insights
    Application Insights Telemetry
    Live Streaming of execution
    Logic Apps as WebHook
    Logic apps integration with Skype/Slack for notification
    Create Logic apps for Twitter Integration with Slack(AI Usage)
    Stay in Cloud





10 OCT 2018


@Azure @ARM @LogicApps

Sunday, October 7, 2018

POWER SHELL COMMANDS

POwer SHELL COMMANDS


get-help workerrole
get-help webrole
get-help *content*
get-help storage
get-command *event

get-eventlog system

get-eventlog system -newest 10 // to get latest 10 log
 
get-eventlog system -newest 10 | where {$_.instanceid -eq 129} // To get the specific event
 
get-eventlog system -newest 10 | where {$_.instanceid -lt 1219} // to get all events less than event id 129
  
get-service | export-csv -path E:\Service.csv -- to export all services to E drive through command 

import-csv E:\Service.csv


TO Export all process in xml format :


get-process | export-clixml -path  e:\training.xml

TO Export all process in txt format :

get-process | out-file -filepath  e:\training.txt

To open in notepad :

invoke-item  e:\training.txt


To get all service in html format:


get-service | convertto-html


get-service | convertto-html | set-content E:\xyz.xml


To retrieve only two columns from Services:


get-service | convertto-html -property name,status



List of service starts with character “S”


get-service s*


To get process which has id less than 100

get-process | where id -lt 100


To Get service which are running using where clause in powershell:


get-service | where {$_.status -eq "running"}

get-service | where {$_.status -eq "stopped"}

Thursday, September 20, 2018

Install httprepl in DotnetCore 2.2 Preview

Install httprepl in DotnetCore 2.2 Preview

While you are working on the .Net Core Preview 2.2 than you may required to  install httprepl, so while Installing dotnet-httprepl from the command prompt using the following command:

dotnet tool install -g --version 2.2.0-* --add-source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json dotnet-httprepl


image


You can verify about the version installed with the following command : dotnet tool list -g


image


#ASP.NET Core

Tuesday, August 28, 2018

Difference between Cloud Service and PaaS App Service


 

In Cloud service you can take control of remote machine.
                                                                    App Service                                                       Cloud Service

App Service In app service you deploy app on FTP, App service also manages by Microsoft.

   You will deploy an application on VM means on physical server, Microsoft manages the virtual machine for us.                          
App service deployment is faster.Cloud Service Deployment process is slower because of physical service.
App service you can’t take the control or remote desktop of FTP.
In App Service you can scale up to 20 instanceWhile in Cloud Service you can scale up to 10000 instance.
However you machine can be shared among many vendors  , so it means multiple application can share same serverThere is dedicated machine in Cloud Service  Which puts you application in high availability set.
You can’t install any softwareYou can install some sort of software in VM that you can.also you can make some configuration as per you need along with utlize almost 700 resources

Thursday, July 26, 2018

Python TypeError must be str not int

Python TypeError must be str not int


While working on Modules using python using an IDE PyCharm i confronted an issue while printing int value using Print function of python.I’ve created a python module which i require to import prior to use.

Now question strikes in mind what actually Module is in Python.


I’ve craeted a fle named as Functions and having the below given code:



def calculate_square_area(length):
return length*length

The structure looks like of a sample application as shown below:

image

Monday, June 11, 2018

[Fiddler] The connection to com failed.

Error-Messages

[Fiddler] The connection to '<the site>.com' failed. 
System.Security.SecurityException Failed to negotiate HTTPS connection with server.fiddler.network.https> HTTPS handshake to <the site>.com (for #3) failed. System.IO.IOException Unable to read data from the transport connection: 
An existing connection was forcibly closed by the remote host. < An existing connection was forcibly closed by the remote host 


Resolution - 

Go to  Tools > Telerik Fiddler Options > HTTPS It's set to ;ssl3;tls1.0 Add tls1.2

Kinldy refer below image for reference.


image

Warm Regards

Sachin Kalia

Tuesday, May 8, 2018

Session about .Net Core 2.0 with Angular in Noida

Session about .Net Core 2.0 with Angular in Noida

Shared my learning about .Net Core 2.0 with Angular with it's inbuilt template and many more in Noida .
Mitigation of Challenges faced with earlier version of .Net
Some glimpse of the day
#dotnetcore2.0#Angular #mvpbuzz #asp.net



Image may contain: Sachin Kalia, standing and screen

Image may contain: Sachin Kalia, standing and screen

Image may contain: 8 people, including Chirag Arora, Vibhor Kaushik, Himanshu Dora, Dinesh Verma and Anirudh Prasad, people smiling, people sitting and indoor

Image may contain: Sachin Kalia, standing and screen


#dotnetcore #Angular

Monday, April 30, 2018

Missing Registration For Location Error while Publishing the API on Azure.

Introduction:

Missing Registration For Location Error Can come when we are trying to publish the web application on azure from Visual studio.

Solution:

I’ve tried various way to resolve this and various website advised to me to update  visual studio or Upgrading Azure SDK will resolve your problem however this didn’t work. So I used alternative approach for publishing.

Steps:


  • Publish your web application using visual studio. It gives this  error. but It creates App Service Plan and App Service in Azure.
  • sign in to portal.azure.com
  • Select the App Service which you have created.
  • image




  • Click on Get Publish Profile.
  • Now Again Go to Visual studio and Publish.




  • This time while publishing select Import.

  • image




  • Select the file which you have downloaded from azure.
  • Click Ok.
  • Click On Publish.
    image


    10. Your Application will get Publish

    #Azure

    Monday, March 26, 2018

    Abstract Factory Pattern Using C# - Real World Example

    While learning about design patterns, I came to understand the most frequently used term, Factory Pattern as well as Abstract factory pattern. I searched the internet and came across numerous learning points. After a lot of search and study, I endeavored to find an actual need for the abstract design pattern.

    In this article, I will explore this pattern in an easy way so that everyone can have a better understanding of it. Down the level, I'm using a Car (Vehicle) example to demonstrate abstract factory pattern.

    An important aspect of software design is the manner in which objects are created. Thus, it is not only important what an object does or what it models, but also in what manner it was created.

    Reference: http://www.dofactory.com/
    Definition
    Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

    Definition

    C#

    I'd keep the structure in such a way as depicted below.
    Participants

    The classes and objects participating in this pattern are:

    • AbstractFactory (IVehicleFactory)
      • declares an interface for operations that create abstract products.
    • ConcreteFactory (MarutiFactory, TataFactory)
      • implements the operations to create concrete product objects.
    • AbstractProduct (ICarEngine, ICarLight)
      • declares an interface for a type of product object.
    • Product (DDis, LED, Revtron, Helogan)
      • defines a product object to be created by the corresponding concrete factory.
      • implements the AbstractProduct interface.
    • Client (Clinet)
      • uses interfaces declared by AbstractFactory and AbstractProduct classes.

    Implementation

    1. using System; 
    2. namespace AbstractFactoryPattern 
    3. interface IVehicleFactory 
    4.     { 
    5.         ICarEngine GetCarEngine(); 
    6.         ICarLight GetCarLight(); 
    7.     } 
    8. class MarutiFactory : IVehicleFactory 
    9.     { 
    10. public ICarEngine GetCarEngine() 
    11.         { 
    12. return new DDiS(); 
    13.         } 
    14. public ICarLight GetCarLight() 
    15.         { 
    16. return new LED(); 
    17.         } 
    18.     } 
    19. class TataFactory : IVehicleFactory 
    20.     { 
    21. public ICarEngine GetCarEngine() 
    22.         { 
    23. return new Revtron(); 
    24.         } 
    25. public ICarLight GetCarLight() 
    26.         { 
    27. return new Helogen(); 
    28.         } 
    29.     } 
    30. class LED : ICarLight 
    31.     { 
    32. public string GetLightInfo() 
    33.         { 
    34. return "Led lights"; 
    35.         } 
    36.     } 
    37. class DDiS : ICarEngine 
    38.     { 
    39. public string GetEngineInfo() 
    40.         { 
    41. return "DDis engine for their diesal cars..."; 
    42.         } 
    43.     } 
    44.     internal class Helogen : ICarLight 
    45.     { 
    46. public string GetLightInfo() 
    47.         { 
    48. return "Helogan Light..."; 
    49.         } 
    50.     } 
    51.     internal class Revtron : ICarEngine 
    52.     { 
    53. public string GetEngineInfo() 
    54.         { 
    55. return "Revtron engine for their diesal/petrol cars..."; 
    56.         } 
    57.     } 
    58.     internal interface ICarLight 
    59.     { 
    60.         string GetLightInfo(); 
    61.     } 
    62.     internal interface ICarEngine 
    63.     { 
    64.         string GetEngineInfo(); 
    65.     } 
    66. class Client 
    67.     { 
    68. private IVehicleFactory vehicleFactory = null; 
    69. public void CreateCarWithLight(string carName) 
    70.         { 
    71. if (carName.ToLower() == "maruti") 
    72.             { 
    73.                 vehicleFactory = new MarutiFactory(); 
    74.                 Console.Write( 
    75.                     $"{carName} uses {vehicleFactory.GetCarEngine().GetEngineInfo()} with {vehicleFactory.GetCarLight().GetLightInfo()} as headlight"); 
    76.             } 
    77. else if (carName.ToLower() == "tata") 
    78.             { 
    79.                 vehicleFactory = new TataFactory(); 
    80.                 Console.Write( 
    81.                     $"{carName} uses {vehicleFactory.GetCarEngine().GetEngineInfo()} with {vehicleFactory.GetCarLight().GetLightInfo()} as headlight"); 
    82.             } 
    83.         } 
    84.     } 
    85. class Program 
    86.     { 
    87. static void Main(string[] args) 
    88.         { 
    89.             Console.Write("**** Welcome to Abstract Factory pattern By DotnetPiper.com *******\n Kinldy enter your car name..."); 
    90.             Client client = new Client(); 
    91.             string carName = Console.ReadLine(); 
    92.             client.CreateCarWithLight(carName); 
    93.             Console.ReadLine(); 
    94.         } 
    95.     } 
    96. }

    Run your application now. The following window will appear.
    C#
    Put the desired car name you would like to know the information about, like Maruti, Tata etc.

    Kindly refer to the following window as a result after you put Maruti.
    C#


    Link to download sample application Abstract Factory Pattern Using C# - Real World Example

      Monday, February 19, 2018

      Workshop on #Microsoft #Azure

      Workshop on #Microsoft #Azure for the students of IIMT College of Engineering, Greater Noida by Sachin Kalia at C# Corner office, Noida.

      cc Mani Gautam Dinesh Kumar Beniwal Atul Gupta

      @dotnetpiper


      Image may contain: 1 person, sitting


      Image may contain: 1 person, indoor


      Warm Regards

      Sachin Kalia

      Thursday, January 4, 2018

      INTRODUCTION

      Custom Service Dependency Injection In .Net Core 1.1

      There are various ways to inject dependency in MVC. Dependency injection is a technique to pass the required Dependency so that the desired action can be performed.
      Dependency Injection In .Net Core
      In this article we will go through with one of the key features of .Net Core, Custom Service dependency injection in .Net core 1.1, particularly at controller’s action level .Here are some important points which will help you to understand the facts easily in the following excerpts:

      Dependency Injection

      Dependency Injection (DI) is a pattern that shows how we can create loosely coupled classes. It means Class A is not directly dependent on class B and an object injects the dependency of another object. A dependency is an object that can be used as service, which is a part of this article.

      Earlier in .Net there were some well-known dependency resolvers like Unity, Autofac and Ninject and so on.

      1. .Net Core allows you to inject dependency out-of-the-box, there is no need to add the reference of the above mentioned dependency resolver. As soon as you create a solution you will be able to configure services easily, .Net Core manages this operation at its level that indeed helps a developer to get rid of this matter.
      2. This article explains about how to configure custom service in .Net core and inject that service object in controller’s constructor as well as in action method. In the earlier versions of .Net it used to not inject the dependency at Action level. This is recently introduced with the release of .Net core. Action level injection of service makes an application lighter than controller level. Consider a scenario when you have a number of action methods defined in a single controller and you have injected the service at controller’s constructor. Though it’s being used at one action only, it looks like it’s not worth it.
      PREREQUISITES
      • Visual Studio 2017 Enterprise/Professional
      • .Net Core 1.1

      IMPLEMENTATION

      In order to understand the dependency injection in .Net core 1.1, kindly refer to the given below image which states how the client application needs an object to access the implementation of given methods.
      Dependency Injection In .Net Core

      Now create a custom service class file as depicted below in screen shot:

      Dependency Injection In .Net Core

      FirstService class file has the following code snippet.

      1. using Microsoft.Extensions.Configuration; 
      2. namespace DotnetPiper.Services 
      3. public interface IFirstService 
      4.     { 
      5.         string WelcomeEquinox(); 
      6.     } 
      7. public class FirstService : IFirstService 
      8.     { 
      9. public string welcomeEquinoxStr { get; set; } 
      10. public FirstService() 
      11.         { 
      12.             welcomeEquinoxStr = "Welcome Folks in .Net Core presentation!"; //Configuration["WelcomeEquinox"];
      13.         } 
      14. public string WelcomeEquinox() 
      15.         { 
      16. return welcomeEquinoxStr; 
      17.         } 
      18.     } 

      There is a startup class file which exists in solution and has two methods ConfigureServices and configure. Refer to the below image to know more about startup class file location under solution structure.

      Dependency Injection In .Net Core

      This method executes its functionality at runtime. Both operations have a different set of objectives as shown below,

      ConfigureServices

      This method gets called by the runtime. Use this method to add services to the container. And it takes one IServiceCollection object as an input. Refer to the given below screenshot.

      Dependency Injection In .Net Core

      Configure
      This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

      Dependency Injection In .Net Core

      Register Your Custom Services

      To register your custom application services in ConfigureService method kindly put an interface definition object type that will be requested from the container. The second type represents the concrete type (class) thaFit will be instantiated by the container.

      1. services.AddSingleton<IFirstService, FirstService>(); 

      If you notice in figure4, it has an IServiceCollection object which registers IFirstService object as singleton. Though there are two more ways to register your dependency in .Net core, those are AddScoped and AddTrsnsient as shown below,

      1. services.AddScoped<ArticlesService>(); 
      2. services.AddTransient<ArticlesService>(); 

      Now create a product controller under controller’s folder and inject dependency in either of controller’s action, as shown below in screen shot,

      Dependency Injection In .Net Core

      Open Product Controller and inject IFirstService dependency in Details action method. Kindly refer to the below image for ref,

      1. public ActionResult Details([FromServices] IFirstService FirstService) 
      2.      {             
      3.          _FirstService = FirstService; 
      4. return Content(_FirstService.WelcomeEquinox()); 
      5.      } 

      Note

      [FromServices] attribute is newly introduced in .Net Core and brings an important role in order to inject abstract dependency at action method level.

      Let’s run an application and see how it works.

      Press F5 and application will open in browser just to ensure that application is up and running.

      Dependency Injection In .Net Core

      Kindly copy and paste the following url to ensure the IFirstService availability at action level.

      http://localhost:64686/product/details
      Dependency Injection In .Net Core

      This is the final outcome which brings information through Custom service
      Dependency Injection In .Net Core

        Wednesday, January 3, 2018

        Register A Chat Bot Using MS Bot Framework

        Recently, I created a Chabot for a purpose which I wanted to register within. After an implementation of Bot using MS Bot framework, it should be registered with https://dev.botframework.com/bots.

        These are a few steps which may help you to register and ready to use.

        Step 1
        Go to https://dev.botframework.com/bots. You will have the following section there as given in the below screenshot.

        Step 2
        Click on "My Bots" and further, click on "Create a bot".

        Chat Bot

        Step 3
        Click on "Create" button as shown in given image and the following window will appear.
        Chat Bot

        Step 4
        Choose the first option from the given screen and click OK.
        Chat Bot

        Step 5
        As soon as you create click ok, it generates AppId which might be essential at down the level during accessing the Bot which you have created.
        Chat Bot

        Step 6
        Click on "Generate an app password" to continue.

        Note
        Kindly save this password in Notepad for future purpose.


        Chat Bot
        Chat Bot

        Step 7:
        After performing all the above steps, it is time to set configuration as given below.
        Chat Bot

        It may prompt you to keep https instead of http,
        Chat Bot
        Step 8

        Once you are done, click on register and it will prompt to as Bot created in the given screenshot.
        Chat Bot

        Step 9
        As soon as you have created and registered your Bot, click on the recently registered Bot as depicted below in the screenshot.

        Chat Bot

        It will take you to the next level which advises you to test your Bot.
        Chat Bot
        Step 10

        Click on the Test button showing in right top corner. Click on that. It will prompt you another window and put "hi" in the chat window. As soon as you type something, it starts responding you which confirms that Bot has been register successfully.
        Chat Bot

        Short circuiting and branching in .NET Core are key concepts to make an application sequential and provide more control over the response.

        The term middleware is used in a .NET Core application either to delegate a request to the next component in the pipeline or short circuit it.

        Middleware has some important aspects as shown below:

        1. It delegates the request to the next component in the pipeline.
        2. Business logic can be written before and after the component is invoked in the pipeline.

        There are three extension methods Run, Map, and Use which can be configured as request delegates.

        Each request delegated can be written as a single line as an anonymous method (aka in-line middleware) or separately as a middleware component.

        These components are responsible for invoking the next delegate in the pipeline or to short circuit it.

        .NET Core request pipeline comprises request delegates, which call one after another as the image shown below:

        Reference: MSDN

        Each delegate can also decide not to pass a request to the next delegate, which is known as short circuiting. An advantage of short circuiting is, it doesn’t pass the request to the following delegate if it doesn’t meet specific criteria. For example, if a request doesn’t have a specific parameter in its URL, then it can short circuit the pipeline and returns the response directly from there.

        On the other hand, branching helps to map the request based on matches and executes the specific branch (can be a method).

        Map and MapWhen extensions are provided by .NET Core by default for branching the pipeline.

        Kindly refer to the image below for better understanding:

        Let’s practically see all this.

        PREREQUISITES

        • Visual Studio 2017 Enterprise/Professional
        • .Net Core 1.1

        IMPLEMENTATION

        To understand the short circuiting and branching in .NET Core 1.1, refer to the figure below for a solution structure:

        Open a startup.cs file and search for configure method; it comes out-of-box with .NET Core applications.

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IFirstService FirstService)         { }
        
        

        CONFIGURE:

        This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

        Figure3.

        SHORT-CIRCUITING:

        To meet purpose I’ve written code using Use extension method and set a limitation so that if a specific request contains a query string in its URL, then it should not go further in pipeline otherwise it should go till the Run method.

        The code snippet for short-circuiting is shown below:

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IFirstService FirstService)         {             app.Use(async (context, next) =>             {                 string agent = context.Request.Headers["user-agent"].ToString();                 if (!string.IsNullOrEmpty(context.Request.QueryString.Value))                 {                     context.Response.Headers.Add("X-Frame-Options", "localhost");                                        await context.Response.WriteAsync("Query string is not allowed in Middleware pipeline");                     return;                 }             });         }
        

        Press F5 and run an application.

        Now copy and paste the following URL into your browser: http://localhost:64687/Map3?CustomString

        Now as per the code (if it has a query string in URL) it should short circuit the request pipeline and return a response directly from Use method:

        RESPONSE

        As shown in the screen above it skips the remaining pipeline and responds from the use extension method only. Though Run method always executes if you don’t short circuit.

        The snippet for the run method within an application is given below:

        app.Run(async context =>         {             await context.Response.WriteAsync("Hello from sample application.");         });
        
        The complete code snippet for short-circuiting is given below:
        
        public class Startup
        
        {     public void Configure(IApplicationBuilder app)     {         app.Use(async (context, next) =>         {             // You can write logic that that doesn't write to the Response.             await next.Invoke();             // write logic that doesn't write to the Response.         });         app.Run(async context =>         {             await context.Response.WriteAsync("Hello from sample application.");         });     }
        
        }
        

        Note: If you use the above code segment, await next.Invoke(); which is being used to call next component or further delegate in the pipeline. In this case it is the app.Run() method.

        E.g., kindly copy and paste the following code snippet in your configure method and run an application.

        app.Use(async (context, next) =>             {                 string agent = context.Request.Headers["user-agent"].ToString();                 if (!string.IsNullOrEmpty(context.Request.QueryString.Value))                 {                     context.Response.Headers.Add("X-Frame-Options", "localhost");                     //context.Response.Headers.Add("X-Content-Type-Options", configuration["CustomMessage"]);                     await context.Response.WriteAsync("Query string is not allowed in Middleware pipeline");                     await next.Invoke();                 }             });
        
        app.Run(async (context) =>             {                               await context.Response.WriteAsync(" Welcome Folks in .Net Core presentation!");             });
        

        Output:

        Let’s run an application and see how it works.

        Press F5 and application will open in the browser to ensure that the application is up and running.

        BRANCHING:

        As the name implies, branching means a resembling of the branches of a tree. It’s somewhere same in .NET Core also.

        Map extension method exists in .NET Core which can be used a branching as given below:

        As defined in the screenshot above, map method branches the request pipeline based on the matches of the given request path. If the request path starts with the given path, the branch will execute.

        Code snippet: Keep the code segment in Configure() method of startup file.

        app.Map("/map1", HandleMapMiddlewareOne);
        
        private static void HandleMapMiddlewareOne(IApplicationBuilder app)         {             app.Run(async context =>             {                  await context.Response.WriteAsync("Map Middleware One Called...");                            });         }
        

        app.MapWhen works the same way, as shown in the image depicted below:

        Let’s see this in practice.

        Press F5 to run your application.

        Copy and paste the following URL in browser http://localhost:64687/map1?callingBranching

        Note: Kindly replace localhost port with your application’s one.

        As soon as you execute the URL, it verifies and matches the request and reaches to the branching delegate. In our case, its HandleMapMiddlewareOne and respond directly from there.

        The same way it should work for MapWhen with the bit different condition in the below code snippet.

        app.MapWhen(context => context.Request.Query.ContainsKey("branch"),HandleBranch);
        
        private static void HandleBranch(IApplicationBuilder app)         {             app.Run(async context =>             {                 var branchVer = context.Request.Query["branch"];                 await context.Response.WriteAsync($"Branch used = {branchVer}");             });         }
        

        Press F5 to run your application.

        Copy and paste the following URL in browser http://localhost:64687/custom?branch=dotnetCore

        OUTPUT:

        Hope this helps you to understand Short Circuiting and Branching in .NET Core.

        Happy Coding!