Category: SSMS

MagnusMinds' Commitment to Growth: Never-ending Learning
Feb 19, 2024 3 min read

Introduction:  At MagnusMinds, we passionately believe that the key to success lies in the relentless pursuit of knowledge and growth. Our commitment to fostering a culture of continuous development is not just a statement; it is a way of life for our employees. In this blog, we will delve into the core of MagnusMinds' ethos, exploring the various avenues through which we empower our team members to thrive and excel in their professional journeys.    Investing in Knowledge:  At the heart of MagnusMinds' commitment to continuous development is our robust investment in training programs. We understand that staying ahead in today's dynamic business landscape requires a workforce equipped with the latest skills and knowledge. From specialized workshops to industry conferences, we provide our employees with diverse opportunities to enhance their expertise and stay abreast of emerging trends.    Mentorship Matters:  MagnusMinds places great emphasis on the power of mentorship. Our mentorship programs are designed to foster meaningful connections between experienced professionals and those looking to navigate their career paths. Seasoned mentors not only share their insights but also provide guidance, support, and encouragement, creating an environment where learning is a two-way street.    Tailored Development Plans:  Recognizing that each employee is on a unique professional journey, MagnusMinds takes a personalized approach to development. We work collaboratively with our team members to create tailored development plans that align with their career goals and aspirations. Whether it is acquiring new technical skills or honing leadership capabilities, we ensure that everyone's growth trajectory is supported.    Learning Beyond Boundaries:  MagnusMinds encourages its employees to explore learning opportunities beyond their immediate roles. Cross-functional exposure is not just welcomed; it is actively promoted. This approach not only broadens the skill sets of our team members but also fosters a culture of collaboration and innovation, where diverse perspectives are valued.    Learning from Each Other:  The strength of MagnusMinds lies in its diverse talent pool. We believe that everyone has something unique to offer and learning from each other is a continuous process. Whether through informal knowledge-sharing sessions, collaborative projects, or internal forums, we create spaces where employees can tap into the collective intelligence of the organization.    Celebrating Milestones:  Acknowledging and celebrating milestones is an integral part of MagnusMinds' culture. Whether it is completing a certification, leading a successful project, or achieving a personal development goal, we take pride in recognizing and applauding the efforts of our team members. These celebrations not only motivate individuals but also contribute to a positive and supportive work environment.    Conclusion:  In conclusion, MagnusMinds' culture of continuous development is not just about keeping up with the pace of change; it is about setting the pace. By investing in knowledge, promoting mentorship, offering tailored development plans, encouraging cross-functional learning, fostering knowledge-sharing, and celebrating achievements, we are building a workforce that is not just skilled but also passionate about their professional growth.    At MagnusMinds, learning never stops because our commitment to development is ingrained in our DNA. As we empower our employees to reach new heights, we are not just investing in their future; we are shaping the future of MagnusMinds itself. Join us on this journey of perpetual growth, where every day is an opportunity to learn, evolve, and succeed. 

Exploring Microsoft Power Automate
Feb 15, 2024 3 min read

Microsoft Power Automate Microsoft Power Automate is a cloud-based automation platform that lets users create workflows to automate repetitive tasks and streamline business processes without extensive coding knowledge. Users can connect different applications and services to design workflows visually. Power Automate improves efficiency by automating manual tasks.   How Does Power Automate Work? Power Automate workflow, or flows, are based on triggers and actions. A Trigger initiates the flow, such as receiving an email from a key project stakeholder. An Action is what occurs once the flow is triggered. This may involve creating a task when an email marked as high-importance is received. A flow can have one or more actions.   There are five main types of Power Automate flows, categorized as cloud flows, desktop flows, or business process flows. Cloud flows include: Automated, a flow triggered by an event, for example, sends an email if an item in a SharePoint list is changed. Instant  flows allow users to manually trigger a flow from the mobile or desktop app with the click of a button. As an example, easily send a reminder email to your team before a meeting. Scheduled, which runs at certain times.  Desktop flows are used to automate tasks on the web or your desktop with Power Automate Desktop. Business process flows provide a guide for individuals to complete tasks efficiently. They offer a streamlined user experience, guiding users through organizational processes defined for interactions needing advancement to a specific conclusion. An example of a business process might be "Client Onboarding."   Power Automate Use Cases   You can generate your flow by adding information about what you want to automate.   There are three ways to create your automated flow. You can create your flow from scratch.   Automate tasks or processes using custom templates for cloud flows in Power Automate.   Easily connect to your apps, data, and services using connectors    The Scenario  Our product's effectiveness relies on swift order processing. To achieve this, we've automated the retrieval of new orders from our database's Orders table, ensuring instant access to updated information. This enhances our ability to monitor and manage orders efficiently, optimizing our workflow for seamless operations.   Step-by-Step Guide Microsoft Power Automate provides a pre-built task for sending an email when an item is created in SQL Server. Note: - If your data is stored on-premises, the gateway should be in active mode with the same user logged in. Add New SQL Connection: -  Configure with SQL Server, adding the required details along with the gateway (If your data is stored on-premises).   Add the required parameters to the action.   Add the SQL Server name, and database name, along with the table data you want to include in the email. Schedule the flow as per requirements   Set the email address and dynamic SQL fields you want to send in a mail. The flow is ready. When new data is updated in the table, the flow is triggered at the selected time, and an email will be sent to the users.   Conclusion: By automating the retrieval of newly added order details from our database's Orders table, we have streamlined our order processing workflow significantly. This automated process ensures timely access to updated order information, enabling us to monitor and manage our orders more efficiently. As a result, our organization can better meet customer demands, improve overall productivity, and enhance the quality of our services.

The Ultimate Angular vs React Comparison
Feb 08, 2024 3 min read

Overview  In the ever-evolving landscape of web development, the choice of a JavaScript framework can be akin to selecting the right tool for a complex job. Among the myriad options available, two stalwarts, Angular and React, have risen to prominence, captivating the developer community with their unique approaches to building modern, dynamic user interfaces. By examining factors such as performance, learning curve, and project requirements, we aim to equip you with the insights needed to crack the JavaScript conundrum and make an informed choice for your next project.    What is Angular?  Angular is an open-source JavaScript framework written in TypeScript maintained by Google and its primary purpose is to develop single-page applications. It provides a collection of well-integrated libraries that cover a wide variety of features, including routing, forms management, client-server communication, and more. You can write, compile, test, and update your code with the aid of its development tools.    Key features and concepts of Angular include:  Cross-Platform  Component-Based Architecture  Dependency Injection  Directives  RxJS (Reactive Extensions for JavaScript)  Two-way Data Binding    Advantages of Angular Angular promotes a modular architecture, allowing developers to organize code into separate and reusable modules.  Angular extends HTML syntax. With directives.  Angular uses two-way data binding, meaning that the model state changes automatically whenever any interface element changes.  Angular uses a powerful dependency injection system, making it easier to manage and test components.  Angular is built using TypeScript, a statically typed superset of JavaScript. TypeScript adds static typing, interfaces, and other features that enhance code quality, readability, and maintainability.  Angular provides a powerful CLI that streamlines common development tasks.    What is React?  React is a JavaScript-based UI development library that aims to simplify the intricate process of building interactive user interfaces. It is primarily used for building user interfaces (UIs) for single-page applications where the user interface needs to be dynamic and highly responsive. Developed and maintained by Facebook, React has gained widespread adoption in the web development community due to its declarative and efficient approach to building UI components.   Key features and concepts of React include:  Virtual DOM  JSX Syntax  Component based architecture  Declarative Syntax  Props  Hooks    Advantages of React React uses a virtual DOM to optimize rendering performance. Updates to a virtual version of the DOM are triggered by changes in the UI, and React determines the most effective way to update the real DOM to minimize needless re-renders. It has faster updates with both server-side and front-end support.  Easier debugging with declarative views.  React.js promotes the concept of reusable components, which are self-contained modules that can be used across different parts of an application.  React.js has a large and active community of developers who constantly contribute to its growth and improvement.  React.js is highly scalable and flexible, making it suitable for building applications of any size or complexity.    Quick comparison between Angular and React      Angular vs. React: When to choose which?     Angular or React which is best?  Ultimately, the choice between Angular and React is subjective and depends on the specific needs of your project and your team's preferences and expertise. It's also worth noting that both Angular and React have been widely adopted in the industry and have proven successful in building modern and scalable web applications. 

Database Migration to Microsoft SQL Server
Feb 07, 2024 3 min read

Introduction Migrating Microsoft SQL Server databases from one server to another is a critical task that requires careful planning and execution. Overseeing this migration project, it's essential to have a detailed checklist to ensure a smooth and successful transition. In this blog, we will explore the key steps involved in migrating SQL Server databases and provide a comprehensive checklist to guide you through the process.   Checklist for SQL Server Database Migration 1. Assessment and Planning: Database Inventory: Identify all databases to be migrated. Document database sizes, configurations, and dependencies. Compatibility Check: Verify the compatibility of SQL Server versions. Check for deprecated features or components. Backup Strategy: Ensure full backups of all databases are taken before migration. Confirm the backup and restore processes are working correctly.   2. Server Environment Preparation: Server Infrastructure: Verify that the new server meets hardware and software requirements. Install the necessary SQL Server version on the new server. Security Considerations: Plan for server-level security, including logins and permissions. Transfer relevant security configurations from the old server. Firewall and Networking: Update firewall rules to allow communication between old and new servers. Confirm network configurations to avoid connectivity issues.   3. Database Schema and Data Migration: Schema Scripting: Generate scripts for database schema (tables, views, stored procedures, etc.). Validate the scripts in a test environment. Data Migration: Choose an appropriate method for data migration (Backup and Restore, Detach and Attach, or SQL Server Integration Services - SSIS). Perform a trial data migration to identify and address potential issues.??????? Restore Strategy: Ensure full backups of all databases are available on the new server. Restore databases and confirm the processes are working correctly.   4. Application and Dependency Testing: Application Compatibility: Test the application with the new SQL Server to ensure compatibility. Address any issues related to SQL Server version changes. Dependency Verification: Confirm that linked servers, jobs, database mail, and maintenance plans are updated. Test connectivity to other applications relying on the database.   5. Post-Migration Validation: Data Integrity Check: Execute DBCC CHECKDB to ensure the integrity of the migrated databases. Address any issues identified during the integrity check. Performance Testing: Conduct performance testing to ensure the new server meets performance expectations. Optimize queries or configurations if needed. User Acceptance Testing (UAT): Involve end-users in testing to validate the functionality of the migrated databases. Address any user-reported issues promptly.     Conclusion A successful Microsoft SQL Server database migration requires meticulous planning, thorough testing, and effective communication. Following this comprehensive checklist will help ensure a smooth transition from one server to another while minimizing disruptions to business operations. Regularly communicate with your team and stakeholders throughout the migration process to address any challenges promptly and ensure a successful outcome. Download Checklist for MSSQL Server Migration

Group Ranking with DAX in Power BI
Feb 06, 2024 2 min read

Data visualization and analysis in today's fast-paced business environment require not only precision but also a deep understanding of the tools at our disposal. Power BI, a potent tool in Microsoft's suite, stands out for its ability to handle complex data scenarios. One such scenario is ranking data with multiple grouping dimensions, such as state, city, and revenue. This blog post will guide you through this process in Power BI.    Understanding the Basics  Before we dive into the specifics, let's ensure we have a clear understanding of some key Power BI concepts:    Ranking: This involves sorting data in ascending or descending order. In Power BI, we can use DAX functions like RANKX to achieve this.  Grouping: This refers to categorizing data into segments. Power BI allows grouping in visuals or more advanced grouping in DAX.  DAX (Data Analysis Expressions): A library of functions and operators used in Power BI for creating custom calculations.    The Scenario  Imagine we have a dataset containing sales information across different states and cities over several years. Our objective is to rank these cities within each state based on their annual revenue.    Step-by-Step Guide  Prepare Your Data: Ensure your dataset is properly structured with columns for State, City, Year, and Revenue.  Load Data into Power BI: Import your dataset into Power BI Desktop.  Creating the Rank Measure:  Go to the Data view.  Create a new Measure to calculate the rank. You can do this by using the DAX formula:    Building the Visual:  Switch to the Report view.  Create a table or matrix visual.  Add State, City, Revenue, and the newly created Rank column to the visual.  Conclusion  Ranking and grouping in Power BI offer powerful ways to dissect and understand your data more effectively. By following the steps outlined in this blog, you can now rank cities within states based on revenue, offering valuable insights into regional sales performance.  Remember, the key to mastering Power BI lies in practice and experimentation, so don’t hesitate to try different variations of rankings and groupings to suit your specific data needs.   

API Response Fix: Simple Solutions
Feb 03, 2024 4 min read

Simplifying API Responses with AutoWrapper.Core in .NET Core. Handling API responses effectively is a crucial aspect of building robust and user-friendly applications. In .NET Core applications, the AutoWrapper.Core library comes to the rescue, providing a streamlined way to structure and standardize API responses. In this blog post, we'll explore how to use AutoWrapper.Core to create fixed responses for different status codes in your API. Firstly, you'll need to install the AutoWrapper.Core NuGet package. Add the following line to your project's .csproj file: <PackageReference Include="AutoWrapper.Core" Version="4.5.1" /> This package simplifies the process of handling API responses and ensures a consistent format for success, error, and data messages.   Example: Login Method Let's consider a common scenario, the login method, where we want to ensure fixed responses for both successful and unsuccessful attempts. [HttpPost("Login")] public async Task<ApiResponse> Login([FromBody] Login model) { var user = await _userService.GetUserByName(model.UserName); if (user != null && await _userService.CheckUserPassword(user, model.Password)) { var userResponse = await _tokenService.GenerateToken(user); return new ApiResponse(message: "Login Successfully.", result: userResponse, statusCode: 200); } return new ApiResponse(message: "Invalid Credential.", result: null, statusCode: 401); } In this example, we're using AutoWrapper.Core's ApiResponse class to encapsulate our responses. For a successful login attempt (status code 200), we return a positive message along with the user response. In case of invalid credentials (status code 401), an appropriate error message is provided. ApiResponse Class Now, let's take a closer look at the ApiResponse class from AutoWrapper.Core: namespace AutoWrapper.Wrappers; public class ApiResponse { public string Version { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public int StatusCode { get; set; } public string Message { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public bool? IsError { get; set; } public object ResponseException { get; set; } public object Result { get; set; } [JsonConstructor] public ApiResponse(string message, object result = null, int statusCode = 200, string apiVersion = "1.0.0.0") { StatusCode = statusCode; Message = message; Result = result; Version = apiVersion; } public ApiResponse(object result, int statusCode = 200) { StatusCode = statusCode; Result = result; } public ApiResponse(int statusCode, object apiError) { StatusCode = statusCode; ResponseException = apiError; IsError = true; } public ApiResponse() { } } The ApiResponse class provides flexibility in constructing responses with different components such as the message, result, and status code. It helps maintain a standardized format for all API responses. Create a Custom Wrapper: AutoWrapper allows you to create a custom wrapper by implementing the IApiResponse interface. You can create a class that implements this interface to customize the fixed response. Here's an example: Create a Custom Wrapper: AutoWrapper allows you to create a custom wrapper by implementing the IApiResponse interface. You can create a class that implements this interface to customize the fixed response. Here's an example: using AutoWrapper.Wrappers; public class CustomApiResponse<T> : ApiResponse<T> { public string CustomProperty { get; set; } public CustomApiResponse(T result, string customProperty) : base(result) { CustomProperty = customProperty; } } Configure AutoWrapper: In your Startup.cs file, configure AutoWrapper to use your custom wrapper. You can do this in the ConfigureServices method: services.AddAutoWrapper(config => { config.UseCustomSchema<CustomApiResponse<object>>(); }); Replace CustomApiResponse<object> with the custom wrapper class you created. Use Custom Wrapper in Controller Actions: Now, you can use your custom wrapper in your controller actions. For example: [ApiController] [Route("api/[controller]")] public class MyController : ControllerBase { [HttpGet] public IActionResult Get() { // Your logic here var data = new { Message = "Hello, World!" }; // Use the custom wrapper var response = new CustomApiResponse<object>(data, "CustomProperty"); return Ok(response); } } Customize the CustomApiResponse according to your needs, and use it in your controller actions. This way, you can integrate AutoWrapper with other packages and customize the fixed response format in your .NET application.   In conclusion, by incorporating AutoWrapper.Core into your .NET Core applications, you can simplify the handling of API responses, making your code more readable, maintainable, and user-friendly. Consider adopting this approach to enhance the overall developer experience and ensure consistency in your API communication.

CSS vs SCSS: Key Differences & Examples
Feb 01, 2024 3 min read

What is CSS?  CSS stands for Cascading Style Sheet. We can use it as a scripting language for developing and creating different web pages.It is well like web technology mostly used with HTML and JavaScript. CSS styles are saved in separate files with the .css extension. It is designed to separate content and presentation, like Layout, fonts, and colors.  By separating the content (HTML) from its presentation(CSS), web developers can create consistent and visually appealing designs across multiple pages and ensure a better experience.   What is SCSS? SCSS stands for sassy Cascading Style Sheets. It is a more advanced and evolved variant of the CSS language.It adds additional functionality to CSS and gives web developers more flexibility and power when creating web designs.SCSS contains file extension as .scss. SCSS is a part of the larger Sass (syntactically Awesome Stylesheets) language, which was created to explore the capabilities of traditional CSS. We can add some extra features to CSS using SCSS, like Variables, Nesting, and many more. using these features, we can write the SCSS in a much simpler and quicker way than writing the standard CSS.    Differences between CSS and SCSS: 1. Syntax: Plain text is used for CSS whereas more structured syntax with additional features is used for SCSS. 2. Variables: SCSS allows you to define variables to store commonly used values like font sizes, color, and spacing, whereas CSS does not. CSS example: body{ color: #ffffff; font: $section-font: 'Arial','sans-serif'; font-size: xx-large; padding: 2rem; } SCSS example: $white: #ffffff; $section-font: $section-font: 'Arial', sans-serif; body { color: $white; font: $section-font; font-size: xx-large; padding: 2rem; }   3. Nesting: SCSS language promotes rules that are properly nested whereas regular CSS language does not assign various nested rules. SCSS example: .parent-selector { .child-selector { // Styles for child selector } } .container { width: 100%; h1 { color: blue; font-size: 24px; } } Benefits of Using Nesting in SCSS: 1. Improved Readability: Nesting allows for more organized code structure, making it easier to read and understand the styles. 2. Reduced Repetition: The user can avoid repetitive code by addressing parent elements directly, saving time and effort. 4. Mixins: Mixins are like functions in programming languages, SCSS allows to creation and reuse of code snippets using mixins. CSS example: nav ul { margin: 0; padding: 0; list-style: none; } nav ul li { display: inline-block; margin-left: -2px; margin-right: 2em; } SCSS example: @mixin reset-list { margin: 0; padding: 0; list-style: none; } @mixin vertical-list { @include reset-list; li { display: inline-block; margin: { left: -2px; right: 2em; } } } nav ul { @include vertical-list; } Arguments: Mixins can also take arguments, which allows their behavior to be customized every time they are called. The arguments are specified in the @mixin rule after the mixin's name, as a list of variable names surrounded by parentheses. CSS example: .sidebar { float: left; } [dir=rtl] .sidebar { float: right; } SCSS example: @mixin rtl($property, $ltr-value, $rtl-value) { #{$property}: $ltr-value; [dir=rtl] & { #{$property}: $rtl-value; } } .sidebar { @include rtl(float, left, right); } 5. File Extension: CSS files use the .css file extension, whereas SCSS files use the .scss file extension. 6. Compilation: CSS files are interpreted by web browsers directly, whereas SCSS files must be preprocessed into standard CSS files using a preprocessor such as Sass. 7. Language Used: SCSS is mostly used in the Ruby language while CSS is mostly used in the HTML and JavaScript languages.

AWS Cognito Login: Easy Setup Tips
Jan 31, 2024 2 min read

  To set up the AWS Cognito for the registration/login flow, follow these steps: First Flow: User Registration in Cognito1. Install the following NuGet packages in your .NET project:   <PackageReference Include="Amazon.AspNetCore.Identity.Cognito" Version="3.0.1" /> <PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="5.0.0" /> <PackageReference Include="AWSSDK.SecretsManager" Version="3.7.101.27" /> Declare AWS configuration values in appsettings: "Region": "me-south-1", "UserPoolClientId": "UserPoolClientId", "UserPoolClientSecret": "UserPoolClientSecret", "UserPoolId": "me-south-pool"   Additional Configuration Add authentication in program/startup files to enable sign-in with Cognito. 2. Create a CognitoUserPool with a unique ID in the controller: private readonly CognitoUserPool _pool; private readonly CognitoUserManager<CognitoUser> _userManager; var user = _pool.GetUser(registerUserRequest.LoginId); 3.Add user attributes (email, phone number, custom attributes) using user.Attributes.Add().   user.Attributes.Add(CognitoAttribute.Email.AttributeName, registerUserRequest.Email); user.Attributes.Add(CognitoAttribute.PhoneNumber.AttributeName, registerUserRequest.Mobile); user.Attributes.Add("custom:branch_code", registerUserRequest.BranchCode); user.Attributes.Add("custom:preferred_mode", preferedMode); 4. Create the user: cognitoResponse = await _userManager.CreateAsync(user, registerUserRequest.Password); Check cognitoResponse.Succeeded to determine if the user was created successfully.   Second Flow: User Login with Cognito 1.Search for the user in Cognito using the login ID: var cognitoUser = await _userManager.FindByIdAsync(loginUserRequest.LoginId);   2.Set a password for the Cognito model: var authRequest = new InitiateSrpAuthRequest {    Password = loginUserRequest.Password };   3.Use StartWithSrpAuthAsync to get the session ID: var authResponse = await cognitoUser.StartWithSrpAuthAsync(authRequest);   4.Add MFA method and validate using MFA auth if needed. For MFA validation, set the MFA settings in Cognito:v ar authRequest = new RespondToMfaRequest {        SessionID = validateLoginUserRequest.SessionId,        MfaCode = validateLoginUserRequest.Otp,        ChallengeNameType = ChallengeNameType.SMS_MFA }; authResponse = await cognitoUser.RespondToMfaAuthAsync(authRequest);   Extract tokens from Cognito: authResponse.AuthenticationResult.IdToken authResponse.AuthenticationResult.RefreshToken   Forgot Password Flow 1.Search for the user with LoginId in Cognito and call ForgotPasswordAsync: var user = await _userManager.FindByIdAsync(loginUserRequest.LoginId); await user.ForgotPasswordAsync();   2.Optionally, call ConfirmForgotPassword method in Cognito. _userManager.ConfirmForgotPassword(userID, token, newPassword, CancellationToken cancellationToken) Here, understanding AWS Cognito Authentication Methods and Utilizing Them as Needed.  

Easy Guide to Cancellation Tokens in .NET
Jan 31, 2024 4 min read

In this blog I'll show how you can use a CancellationToken in your ASP.NET Core action method to stop execution when a user cancels a request from their browser. This can be useful if you have long running requests that you don't want to continue using up resources when a user clicks "stop" or "refresh" in their browser. What is Cancellation Token in c#?  Cancellation tokens in C# are used to signal that a task or operation should be cancelled. They allow for the cooperative cancellation of a task or operation, rather than aborting it forcibly.  Why Use Cancellation Tokens? Here are some benefits of using cancellation tokens:  Avoid resource leaks by freeing up un-managed resources linked to the task  Stop further processing when a task is no longer needed  Improve responsiveness by quickly responding to cancellations  Easy propagation of cancel requests in child tasks  Without cancellation logic, long-running tasks will continue processing in the background even if no longer needed.  You can use cancellaiontoken in any action method or project. Here I am taking one example of .NET web API.  Here, I have created a web API project in .NET, and the above image shows the default controller for the web API, which includes the WeatherForecastController. In that, I have added some log information and added one 10-second task delay that means when this line is executed it will wait for 10 seconds after the next line is executed.  I have added task delay because it is better to understand CancellationToken.  If we hit the URL /GetWeatherForecast then the request will run for 10s, and eventually will return the message. So now, what happens if the user refreshes the browser, halfway through the request? The browser never receives the response from the first request, but as you can see from the logs, the action method executes to completion twice - once for the first (canceled) request, and once for the second (refresh) request.  Whether this is correct behavior will depend on your application.    ASP.NET Core provides a mechanism for the webserver to signal when a request has been canceled using a CancellationToken. This is exposed as HttpContext.RequestAborted, but you can also inject it automatically into your actions using model binding.  Using CancellationToken in your method  CancellationTokens are lightweight objects that are created by a CancellationTokenSource. When a CancellationTokenSource is cancelled, it notifies all the consumers of the CancellationToken. This allows one central location to notify all of the code paths in your app that cancellation was requested.  When cancelled, the IsCancellationRequested property of the cancellation token will be set to True, to indicate that the CancellationTokenSource has been cancelled.  Lets consider the previous example again. We have a long-running action method . As it as an expensive method, we want to stop executing the action as soon as possible if the request is cancelled by the user.  The following code shows how we can hook into the central CancellationTokenSource for the request, by injecting a CancellationToken into the action method, and passing the parameter to the Task.Delay call.  MVC will automatically bind any CancellationToken parameters in an action method to the HttpContext.RequestAborted token, using the CancellationTokenModelBinder.    This model binder is registered automatically when you call services.AddMvc() (or services.AddMvcCore()) in Startup.ConfigureServices().  With this small change, we can test out our scenario again. We'll make an initial request, which starts the long-running action, and then we'll reload the page. As you can see from the logs below, the first request never completes. Instead the Task.Delay call throws a TaskCancelledException when it detects that the CancellationToken.IsCancellationRequested property is true, immediately halting execution.  Summary Users can cancel requests to your web app at any point, by hitting the stop or reload button on your browser. Typically, your app will continue to generate a response anyway, even though Kestrel won't send it to the user. If you have a long-running action method, then you may want to detect when a request is canceled, and stop execution.  You can do this by injecting a CancellationToken into your action method, which will be automatically bound to the HttpContext.RequestAborted token for the request. You can check this token for cancellation as usual, and pass it to any asynchronous methods that support it. If the request is canceled, an OperationCanceledException or TaskCanceledException will be thrown.