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
Cookie and token authentication in ASP.NET Core
Building an authentication filter with cookie and token in ASP.NET Core solves a common production problem: browser users need durable cookie sessions, while APIs, mobile apps and partner integrations need bearer credentials. For the C# Corner Annual Conference 2020 audience, this maps directly to modern .NET estates, particularly when an established portal and a new cloud service share a domain, business rules and identity data.
The design goal is one ClaimsPrincipal and one authorisation model, not a custom login branch inside every controller. ASP.NET Core’s authentication middleware should choose a handler, populate HttpContext.User, and leave filters and policies to decide what an authenticated caller may do. This separation prevents a protected endpoint from accidentally checking the wrong header or accepting an unverified token.
Australian teams in Sydney and Melbourne often have this mixed requirement: established intranets and customer portals sit beside Azure-hosted APIs used by interstate branches. Brisbane teams may also support field devices and partners calling the same service over intermittent mobile links. A cookie suits normal browser navigation; a short-lived bearer token usually fits machine-to-machine or mobile access better.
In practical Australian team language, this should survive an “arvo check”—a quick afternoon sanity test: is the credential obvious, where does it live, and what happens when it expires? That plain question is especially important under the Privacy Act 1988 and Australian Privacy Principles, with the ASD Essential Eight providing another useful security benchmark. A hybrid scheme should simplify sign-in rather than become an unmanaged second identity store.
| Concern | Cookie path | Bearer path |
|---|---|---|
| Credential transport | Browser cookie sent on a matching request | Authorization: Bearer ... header |
| Best fit | Interactive portal and server-rendered pages | API, mobile client and service integration |
| Validation | Protected authentication ticket | Signature or introspection, plus token claims |
| Main risk | Cross-site request forgery and stolen sessions | Credential leakage, replay and weak validation |
| Lifetime | Cookie and ticket expiry, with optional server invalidation | exp, nbf, short access life and refresh rotation |
| Logout | Removes the cookie; complete revocation needs extra state | Requires refresh-token revocation or a deny list |
Decide what each credential proves
Authentication establishes who the caller is; authorisation decides what that caller may do. An MVC action filter runs after the authentication middleware, so it should consume HttpContext.User rather than decode a JWT or inspect a raw cookie itself. Manually replacing the principal in a filter risks bypassing signature checks, token-validation events and cookie logout behaviour.
A cookie is the best fit for interactive browser navigation because the browser returns it automatically and the server validates a protected ticket. A bearer token is better suited to APIs, mobile clients and service calls because the client presents its credential in the Authorization header. Require HTTPS and validate the signature, issuer, audience and expiry; for an opaque token, use introspection instead of treating unreadable content as verified claims.
Prepare the ASP.NET Core project
Use an ASP.NET Core host that supports the client type and install Microsoft.AspNetCore.Authentication.JwtBearer at the version matching the target runtime. ASP.NET Core Identity applications can use their existing cookie registration; avoid adding a second cookie scheme with overlapping names. Keep authority, audience and signing information in user secrets, environment settings or a secret store rather than appsettings.json.
The pipeline order matters: call UseAuthentication before UseAuthorization and before MVC. The middleware asks the default scheme to authenticate each request, creates the principal and stores it on HttpContext.User. Controllers and filters then apply authorisation. This gives Razor views and REST actions one request identity without attaching credential logic to each action.
Route cookies and bearer tokens
ASP.NET Core’s PolicyScheme can act as the hybrid router. It forwards authentication to a named cookie or bearer handler, preserving the standard handlers instead of reimplementing cryptographic validation. This forwarding scheme gives the browser path the cookie handler and the API path JWT validation.
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "Hybrid";
options.DefaultChallengeScheme = "Hybrid";
})
.AddCookie("Cookies", options =>
{
options.Cookie.Name = "__Host-App.Auth";
options.Cookie.HttpOnly = true;
options.Cookie.Path = "/";
options.Cookie.SameSite = SameSiteMode.Lax;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
})
.AddJwtBearer("Bearer", options =>
{
options.Authority = configuration["AzureAd:Authority"];
options.Audience = configuration["AzureAd:Audience"];
options.RequireHttpsMetadata = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ClockSkew = TimeSpan.FromMinutes(2)
};
})
.AddPolicyScheme("Hybrid", "Cookie or bearer", options =>
{
options.ForwardDefaultSelector = context =>
{
var header = context.Request.Headers["Authorization"].FirstOrDefault();
if (header?.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase) == true)
return "Bearer";
if (context.Request.Cookies.ContainsKey("__Host-App.Auth"))
return "Cookies";
return context.Request.Path.StartsWithSegments("/api")
? "Bearer"
: "Cookies";
};
});
The selector gives an explicit Authorization header precedence, then recognises the cookie, and finally uses the path to choose the challenge. A request to /api without credentials should receive a 401 response, whereas a browser request without a session should be redirected to sign-in. If both credential types arrive together, define that precedence as a security decision; the sample favours the token, but a custom handler can reject the ambiguous request.
Harden browser and token sessions
The cookie settings in the sample create a host-only, secure, HTTP-only cookie whose __Host- prefix requires Secure, Path=/ and no Domain attribute. SameSite=Lax blocks the cookie on most cross-site POST requests, but it is not a substitute for anti-forgery tokens. Any state-changing MVC or Razor endpoint that accepts cookies should validate an anti-forgery token, and CORS with credentials must list exact origins rather than *. A cookie required across separate sites needs SameSite=None, Secure and a stronger cross-site request forgery defence.
Bearer tokens need equally strict controls. The JwtBearer handler should validate the signing key, permitted algorithms, issuer, audience, not-before time and expiry, and it should run over TLS. Keep access tokens short-lived, store refresh tokens securely and rotate them on use. If the application uses opaque tokens, validate them through an authorisation server; do not decode them and treat their contents as claims without verification.
Cookie encryption also depends on the ASP.NET Core Data Protection key ring. In a multi-instance Australian Azure deployment, persist that ring in shared storage or Key Vault and establish a rotation policy; otherwise a restart can invalidate sessions. Sign-out removes the browser cookie, but a copied cookie can remain usable until it expires unless the design adds server-side revocation.
Apply authorisation through policies
After authentication, use authorisation policies to express business rules. The built-in AuthorizeAttribute and RequireAuthenticatedUser are safer than a bespoke filter that re-reads credentials. A policy can demand a normalised tenant claim, while resource ownership or role checks can use custom requirements and handlers.
services.AddAuthorization(options =>
{
options.AddPolicy("TenantUser", policy =>
{
policy.RequireAuthenticatedUser();
policy.RequireClaim("tenant_id");
});
});
Apply this policy with [Authorize(Policy = "TenantUser")]. Cookie and token identities often use different claim shapes: roles may arrive as role, while API permissions may appear in scope or scp. Normalise these only after the respective handler validates the credential, for example in JwtBearerEvents.OnTokenValidated. Keep tenant identifiers server-controlled, and perform record-level checks in the service layer where the requested resource is available.
Test the complete authentication flow
Exercise the real middleware with integration tests based on TestServer or WebApplicationFactory. A test client that retains cookies can sign in and call the same action that a token client calls with an Authorization header. Using the production cookie and JwtBearer handlers is important: a fake authentication handler can prove controller behaviour while hiding routing, validation and challenge defects.
Cover the outcomes that matter: no credential on /api returns 401 rather than a login redirect; a valid cookie establishes a principal; a valid token does the same; expired, malformed, wrong-issuer and wrong-audience tokens fail; and a valid token without the required scope is forbidden. Also test a state-changing browser POST without an anti-forgery token, and decide what happens when cookie and bearer credentials arrive together. Verify UseAuthentication still precedes UseAuthorization.
Keep token-expiry assertions in UTC. Melbourne’s daylight-saving transitions affect human-readable logs, but they must never alter not-before or expiry validation; construct boundary tokens around UTC times and allow only the deliberate clock-skew tolerance.
Operate the hybrid scheme in production
Operate the two credential paths as separate security journeys even when they share a scheme. Log the selected scheme, authentication result, tenant identifier and correlation ID, but never log the cookie, Authorization header or full token. Monitor failure rates, refresh-token reuse where applicable and repeated issuer-key retrieval. These signals reveal attacks and authority outages without placing reusable secrets in the telemetry pipeline.
Manage the Data Protection key ring and token-signing keys through a documented rotation process. Key Vault and managed identities suit many Australian Azure estates, but key access still needs least privilege, audit alerts and a recovery runbook. Deploying across Sydney and Melbourne regions should not silently duplicate identity data; confirm data-residency and contractual requirements for the chosen tenant and region.
Treat claims and authentication records as personal information. Australian Privacy Principles require purpose limitation, security, access controls and correction mechanisms, while the Privacy Act 1988 governs many covered organisations. Retain logs only as long as needed, restrict token-revocation data and prepare a notifiable-data-breach process. With validated handlers, normalised claims and deliberate challenges, the hybrid filter gives browser and API users separate credentials under one dependable authorisation model.
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