Magnus Mårtensson
Microsoft Regional Director, Azure MVP, CEO Loftysoft
Avirag Jain
Director & CTO R Systems
Mahesh Chand
Founder C# Corner, CEO Mindcracker
Chris Gali
CEO & Co-Founder Graphite
Subinder Khurana
Chief Architect StoryProcess, Founder NASSCOM DeepTech Club
Bryan Rishforth
Investor, Chairman Graphite
Bryn Everson
Director Biz Dev Graphite
Raj Tiwari
Digital Transformation Leader, Futurist and Visionary
Joseph Guadagno
Microsoft MVP, Lead Quicken Loans
Nikita Sachdev
Entrepreneur, Blockchain Enthusiast & Advisor, Social Media Influencer
Doug Wagner
COO & Founder Adapt Technical Group
Ritesh Modi
Architect, Senior Evangelist, Cloud Architect
Crystal Wenrick
Director Communications Mindcracker
Allen O’Neill
Microsoft MVP, Consulting Engineer/Architect
Praveen Kumar
CEO MCN Solutions
Chris Love
Founder Love2Dev, Microsoft MVP, Author
Sanjay Vyas
Microsoft Regional Director, Microsoft MVP, Founder & CEO SkillLabs Technologies
Veena Sarda
Deep Learning Consultant, Author
Sekhar Srinivasan
C# Corner MVP, Microsoft Certified Trainer, Pluralsight Author
Lalit Bansal
Founder & CEO - EIY SYS
Navdeep Garg
CEO Revinfotech
Prakash Tripathi
Tech Manager/Leader, Microsoft MVP, Blogger
Bhavna Jain
Breakthrough Consultant
Naveen Sharma
Enterprise Architect, Leadership Coach, Author
Vidya Vrat Agarwal
Principal Architect, Microsoft MVP, Author
Sheetal Agarwal
Founder Clownselors, Medical Clown, Trainer
Abhishek Kant
Founder GTM Catalyst
Vishnu Saran
Founder & CEO VoiceQube
Sandeep Soni
Founder & CEO Deccansoft, Microsoft Certified Trainer
Parveen Malik
AVP InfoSec & Vulnerability Management, Information Security Expert
Nitin Pandit
Microsoft MVP, Developer Evangelist, Author
Niloshima Srivastava
C# Corner MVP, Tech Architect, Trainer, Blogger
Bala Chirtsabesan
Senior Software Engineer at Microsoft, Author
Manoj Mittal
Sr. Technical Architect, C# Corner MVP, Author
Chandni Di
Co-Founder Voice of Slum
Vithal Wadje
Technical Lead, Microsoft MVP, Author
Shivam Ahuja
Founder SkillCircle, Business Mentor
Chervine Bhiwoo
Solution Architect, Microsoft MVP, Author
Saurabh Jain
Vice President Paytm, Founder Fun2Do Labs, Author
Vinay Solanki
Head IoT at Lenovo, Founder IoT-NCR
Anshu kumari
Founder Blockchainkids, Inventor, Trainer
Amit Singal
CEO Startup Buddy
Dev Pratap
Co-Founder & CEO Voice of Slum
Amey Vartak
Technology Consultant, Full Stack Developer, C# Corner MVP, Author
Viswanatha Swamy
Principal Software Engineer, C# Corner MVP, Author
Sanket Verma
Research Engineer @ Ballistics (Forensics) and Chair, PyData Delhi
Sourabh Somani
Lead Developer, Microsoft MVP, Author
Abhishek Mishra
Software Architect, C# Corner MVP, Author
Siddharth Vaghasia
Technical Consultant, C# Corner MVP, Blogger
Bassam Alugili
Senior Software Specialist, Database Expert
S Ravi Kumar
Solution Architect, C# Corner MVP, Author
Sundaram Subramanian
Full Stack Developer, C# Corner MVP, Speaker
Deepesh Somani
Solution Architect, Microsoft MVP, Author
Debasis Saha
Technical Project Manager, C# Corner MVP, Blogger, Author
Vipul Jain
Software Architect, C# Corner MVP, Author
Akshay Patel
Technical Architect, Microsoft Certified Trainer, C# Corner MVP, Author
Stephen Simon
RPA Developer, Evangelist, Author
Vivek Sharma
Founder Kingster636, AR/VR Specialist
Jeetendra Gund
Technical Lead, C# Corner MVP, Author
Sujal Beniwal
AI Enthusiast, Student
M Viknaraj
Microsoft MVP, Azure Architect, Author
Prasham Sabadra
Software Architect, C# Corner MVP, Trainer, Author
Aakash Maurya
Senior Developer, C# Corner MVP, Speaker
Ankit Sharma
Senior Software Engineer, C# Corner MVP, Author
Mangesh Gaherwar
Team Lead, C# Corner MVP, Author
Viral Jain
Technical Consultant, C# Corner MVP, Author
Bhasker Das
Solution Architect, Evangelist
Manish Dwivedi
Associate Project Manager
Ck Nitin
Programmer, Author
Rohit Gupta
Technical Trainer, Author
Manish Tewatia
Full-stack Marketer, UX Designer
Bhavya Gaur
Technical Illustrator
Rohit Tomar
SEO/SMO Expert
Web Track
Cloud & Data Track
Dev Track
Registration & Breakfast
Future of Desktop Apps with JS (ElectronJs)
Nitin Pandit
Building Serverless Microservices Using Microsoft Azure
Vithal Wadje
Innovating RPA: A Robot for Every Person
Stephen Simon
Managing Cloud Storage Accounts using Logic Apps
Viknaraj Manogararajah
Data visualization using Python
Sekhar Srinivasan
Going Cross platform with AR Foundation
Vivek Sharma
Keynote
Managing your Azure dependencies in ASP.NET Core apps using VS
Bala Chirtsabesan
Securing Applications on Intelligent Azure
Abhishek Mishra
Getting started with Blazor the Framework of Future
S Ravi Kumar
Lunch
Build Progressive Web Apps using Angular 9
Debasis Saha
Build and deploy to any platform using Azure DevOps
Chervine Bhiwoo
Deep Dive in Azure Service Bus
Akshay Patel
Build a Native Mobile Application using React Native and JavaScript
Joseph Guadagno
Making sense of Web Job, Web Job SDK and Functions in Azure
Prakash Tripathi
CloudFront Distribution in AWS
Viral Jain
Tea Break
Introduction to PowerBI
Aakash Maurya
Build Advanced SPFx solutions with React and Graph API
Siddharth Vaghasia
Build Business Intelligence Analyst (BIA) Skills
Sundaram Subramanian
Deep dive of Power Platform – AI BUILDER
Prasham Sabadra
Panel 1
What's new in SharePoint development
Vipul Jain
Build a SSO (Single Sign On) based Native JavaScript application with Microsoft Identity within 10 minutes
Manoj Mittal
Panel 2
Applications and working of AI
Veena Sarda
Deploying serverless API's with .Net core 3.0 on AWS & Azure
Amey Vartak
Panel 3
Blockchain with .NET Core (Ark)
Anshu Kumari
Closing Note & Prize Distribution
Dev Track
Cloud Track
Architecture Track
Emerging Tech Track
Registration & Breakfast
Creating Full-Stack Web Apps Using Server-Side Blazor
Ankit Sharma
Real time face recognition with MS Cognitive Services
Niloshima Srivastava
Building Scalable APIs with GraphQL
Jeetendra Gund
Future of development with AI and Blockchain
Navdeep Garg
Debugging Tips and Tricks with Visual Studio 2019
Joseph Guadagno
Azure Containers
Abhishek Kant
Enterprise Architecture
Naveen Sharma
Bot Framework - learn it fast and look like a boss!
Allen O’Neill
Keynote
.Net Core & C# 8 Performance
David McCarter
Working with Azure kubernetes services
Ritesh Modi
Becoming an Architect
Vidyavrat Agarwal
Why Techies Need to Learn Product Management
Saurabh Jain
Lunch
Build a rules engine in .Net Core
Sanjay Vyas
Building CI and CD Pipeline using Azure DevOps
Sandeep Soni
Entity Framework Core - Tips and Tricks, Performance Optimization, and Tuning
Bassam Alugili
Hacking your way into Data Science
Sanket Verma
Speed up your .Net Core Website
Sourabh Somani
Azure
Magnus Mårtensson
Demystifying Open Distro for Elasticsearch
Suman Debnath
Future of Data
Shivam Ahuja
Tea Break
gRPC with C# and .Net Core
Mangesh Gaherwar
Panel 1
Essentials of Cloud security
Parveen Malik
Power platform and Dynamics 365
Deepesh Somani
Microservices - the gRPC Way
Viswanatha Swamy
Panel 2
Reserved
Reserved
Closing Note & Prize Distribution
Choosing Multiple Implementations with ASP.NET Core Keyed Services
Dependency injection is a staple of the C# and ASP.NET Core material associated with the C# Corner Annual Conference 2020. Using keyed services in ASP.NET Core DI for multiple implementations extends a familiar idea: several classes can satisfy one contract, while the consuming code identifies the exact implementation it needs. That matters in systems where storage, messaging, payments or identity providers vary by environment.
Most Australian product teams have inherited a DI container that works well: controllers ask for an interface, and the container supplies the implementation. The awkward case appears when one interface has several valid implementations. A Sydney fintech might need a BPAY flow beside its card-payment flow; a Melbourne SaaS team might send notifications through one channel in production and another during testing. During an arvo catch-up, the distinction can be stated simply: register both, then select the right one. Keyed services, introduced in .NET 8, make that selection part of DI rather than a home-grown resolver.
Why keyed services solve a familiar problem
Consider a document service with Azure Blob and Amazon S3 implementations. The contract should stay stable, while configuration identifies which backend a deployment uses. This is also where Australia’s cloud market becomes relevant: many buyers evaluate Microsoft Azure and AWS, often asking specifically about Australian regions, data residency and controls mapped to the ACSC Essential Eight. Keyed registration can express those supported choices without creating a large provider switchboard.
| Concern | Unkeyed registration | Keyed registration |
|---|---|---|
| Implementation set | Several descriptors share a service type | Several descriptors share a service type and use different keys |
| Selection | Usually requires filtering IEnumerable<T> |
Service type and key identify the desired descriptor |
| Consumer access | GetService<T> or constructor injection |
GetKeyedService<T> or FromKeyedServices |
| Lifetime | Singleton, scoped or transient | Singleton, scoped or transient |
| Discovery | IEnumerable<T> can list ordinary registrations |
Keyed registrations are excluded from ordinary IEnumerable<T> resolution |
With ordinary registration, multiple implementations are usually exposed through IEnumerable<T>. A consumer receives all of them and applies its own selection logic, while direct injection of IStorageService normally selects one registration. Keyed registration adds a second discriminator: the service type and the key together identify a descriptor. IStorageService registered under aws-s3 is a different container entry from the same contract registered under azure-blob.
That extra dimension solves selection at the composition root, but it does not replace a good abstraction. If every implementation needs the same operations, one narrow interface remains easier to test than a collection of provider-specific classes. Use a key when the choice is stable and meaningful, such as a deployment channel, tenant tier, storage backend or notification provider. Do not create a key for every method or temporary condition; the registration list will become harder to understand than the code it replaces.
Registering implementations with stable keys
Start by naming the contract and defining keys in one place. Keeping literal values in a shared class prevents small spelling differences from producing missing-service errors at runtime. A minimal registration can look like this:
public static class StorageKeys
{
public const string AzureBlob = "azure-blob";
public const string AwsS3 = "aws-s3";
}
builder.Services.AddKeyedSingleton<IStorageService, AzureBlobStorageService>(
StorageKeys.AzureBlob);
builder.Services.AddKeyedSingleton<IStorageService, S3StorageService>(
StorageKeys.AwsS3);
builder.Services.AddKeyedScoped<IAuditSink, SqlAuditSink>("sql-audit");
Each AddKeyed call creates a descriptor with the contract, implementation, lifetime and key. AddKeyedSingleton, AddKeyedScoped and AddKeyedTransient mirror their ordinary counterparts. The same implementation can be registered under more than one key when that genuinely helps, while a keyed and an unkeyed registration remain separate entries. Registering the implementation by type alone does not make it available to GetRequiredKeyedService.
Factories are useful when construction needs services from the container, but they should not conceal key selection in unrelated business logic. For example, a factory can create a storage client using IOptionsMonitor and then attach provider-specific configuration. Keep the factory in the composition root and make the selected key visible at registration. Developers can cross-check the pattern against the Momasphere developer resources before adapting it to their own composition root.
Resolving the implementation you need
Consumers can request a keyed service with the FromKeyedServices attribute in an ASP.NET Core action or controller parameter:
using Microsoft.AspNetCore.Mvc;
[HttpPost]
public IActionResult Upload(
[FromKeyedServices(StorageKeys.AzureBlob)] IStorageService storage,
IFormFile file)
{
using var stream = file.OpenReadStream();
storage.Store(file.FileName, stream);
return Accepted();
}
The attribute is resolved by MVC’s dependency injection integration. Code that works with IServiceProvider can call GetKeyedService<T>(key) when absence is acceptable or GetRequiredKeyedService<T>(key) when it is a configuration error. The latter throws if the key is missing, which is usually preferable to silently returning null and failing later during an upload or payment. Resolution still respects the descriptor’s lifetime, so a scoped keyed service remains request-scoped.
For runtime choices, validate a request value against a known map, then resolve the corresponding key. A direct service-provider call inside a controller is acceptable for this dispatcher pattern, although constructor or action injection produces clearer dependencies when the choice is fixed. Keys are objects, so strings, enums or dedicated records can be used. Strings remain common in attributes because their equality is easy to inspect; central constants should preserve exact casing and avoid user-supplied text.
Lifetimes, validation and failure modes
Keyed services do not introduce special lifetime rules. A keyed singleton is created once per application container, a keyed scoped service once per request scope, and a keyed transient service on each resolution. The singleton and scoped cautions still apply. If a singleton keyed implementation captures a scoped dependency, validation can report a scope mismatch, and disabling validation can turn that mistake into long-lived captive state.
Registration mistakes produce predictable failures. A missing key causes GetRequiredKeyedService to throw, and an unkeyed request never matches a keyed descriptor. If the same service type and key are registered more than once, the last registration wins; use distinct keys when both registrations must remain available. An ordinary IEnumerable<T> request does not aggregate keyed registrations either. If callers need every implementation, model an explicit registry or register an ordinary collection deliberately.
Startup validation and tests deserve particular attention. Enable ValidateOnBuild to expose unresolved constructor dependencies during application start, while ValidateScopes catches scoped services used from the root provider. Tests should cover the selected key, the missing-key path and each concrete implementation. A fake registered under a test-only key can make test intent obvious, but the production key should remain visible in the test setup so a renamed constant cannot quietly bypass coverage.
Designing keys for real applications
The safest keys describe a business capability rather than a random implementation detail. Names such as primary-documents, archive-documents or event-notifications remain meaningful when Azure or AWS changes behind them. Keys derived from class names encourage callers to depend on infrastructure choices. That is not always wrong: if a request genuinely means “use S3”, aws-s3 is clearer than an abstract label. The important decision is whether the key represents policy, environment or infrastructure.
Dynamic values require restraint. Do not register a new service descriptor for every tenant or incoming identifier; the service collection is built at startup, and unbounded key generation defeats its purpose. Pre-register supported choices and use a dispatcher to select one. Treat the key as selection, not authorization: a caller permitted to request a document must still pass server-side policy checks for that tenant, subscription and operation.
Australian teams should also test operational assumptions that accompany each implementation. Azure and AWS clients can expose different retry, timeout and data-residency behaviour, while teams distributed across Australian Eastern Standard Time and Australian Eastern Daylight Time need schedules expressed in UTC with clear local conversions. Logging the selected key, provider and correlation ID helps a support engineer in Brisbane or Adelaide trace a failure without exposing document names or credentials.
Adoption can remain incremental. A service can first be registered normally, then moved behind a key when a second implementation becomes real. Avoid using keyed DI for a single implementation merely because it is fashionable; plain constructor injection is clearer. Once multiple implementations exist, however, a controlled set of keys moves the selection decision into configuration, keeps consumers concise and gives tests a precise seam. The result is a container whose behaviour can be explained by service type, lifetime and key rather than by hidden resolver conventions.
1, CBD, Maharaj Surajmal Road, Near Yamuna Sports Complex, Delhi, 110032
GENERAL QUERIES
Manish Tewatia
manish@csharpcon.com
+91-9718-431-042
TICKET QUERIES
Atul Gupta
conference@csharpcon.com
+91-9910-125-804