Middle · Trace · Antiforgery binding

Execution context: this is the complete portable .NET9 console companion, using ordinary BCL code. Trace its exact stdout and justify each state or comparison; it does not start the external ASP.NET server or SQL database.

Think through your answer before opening the explanation.

Production engineering

using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;

var expected=new Purpose("one","publish"); foreach(var offered in new[]{new Purpose("one","publish"),new Purpose("two","publish"),new Purpose("one","delete")})Console.WriteLine(offered==expected);
record Purpose(string Owner,string Action);
Reveal answer and reasoning

The output lines, in order, are “True”; “False”; “False”. The portable .NET9 console companion compares three Purpose records against the expected owner one and action publish. The first record matches both fields and prints True. Changing owner prints False, and changing action prints False. Record value equality supplies those results. These publicly known strings are not security tokens, signatures or antiforgery cookies, and an attacker could construct them freely.

No server or cryptographic validator runs in this companion. Its narrow lesson is that matching one part of a context does not establish a full match; the real framework example is required for actual token issuance and validation.

The cookie is explicitly nonsecure for this Development-only loopback exercise, and there is no authenticated business permission. Those choices must not be presented as production cookie guidance. A successful token check also does not consume a nonce or create a request receipt, so repeating an authorized business command would need its own semantics. Restarting the ephemeral provider invalidates old pairs rather than preserving a shared key ring across replicas.

A deployed application must define TLS termination, persistent or shared key ownership, identity binding and authorization separately. No one response or token comparison establishes all those properties together.

What a strong answer covers

  • Exact output: True | False | False
  • The portable .NET9 console companion compares three Purpose records against the expected owner one and action publish.
  • The cookie is explicitly nonsecure for this Development-only loopback exercise, and there is no authenticated business permission.

Common pitfall

The cookie is explicitly nonsecure for this Development-only loopback exercise, and there is no authenticated business permission. Those choices must not be presented as production cookie guidance. A successful token check also does not consume a nonce or create a request receipt, so repeating an authorized business command would need its own semantics. Restarting the ephemeral provider invalidates old pairs rather than preserving a shared key ring across replicas. A deployed application must define TLS termination, persistent or shared key ownership, identity binding and authorization separately. No one response or token comparison establishes all those properties together.

Follow-up questions

  1. How would sharing Data Protection keys across replicas differ from using an idempotency key for one business command?
  2. Why should a repeated valid token increase the classroom counter twice even though a duplicate business command might replay only once?

Self-review

Choose what to revisit. These marks are your own assessment and are separate from lesson completion.

Primary references

Open lesson and code ↗

← All interview questions