Dosi Bridge

Dosi Bridge Digital Operations & Software Innovation – Business Research Infrastructure for Development, Growth & Engineering

HttpClient DNS changes can leave a .NET service calling an old server through reused connections. A healthy replacement ...
11/11/2026

HttpClient DNS changes can leave a .NET service calling an old server through reused connections. A healthy replacement is not enough if callers keep using the route that existed before the cutover.

A host name is not a live subscription to its current address. HttpClient resolves DNS when it creates a connection. If it reuses an existing connection, that socket still leads to the endpoint it originally reached.

The common mistake is assuming that a long-lived client automatically follows DNS record expiry. HttpClient does not track DNS TTLs itself. The opposite fix, creating and disposing a new client with its own handler for every request, adds connection churn and can exhaust ports under load.

For real projects, choose a lifetime strategy deliberately:
- Share a long-lived client backed by SocketsHttpHandler and configure PooledConnectionLifetime. The two-minute value in the example is illustrative; choose an interval for your expected network changes.
- Or create short-lived clients through IHttpClientFactory, which manages pooled handlers. Do not capture a factory-created client forever and expect handler rotation to update it.
- Keep old endpoints available through the planned overlap, then observe traffic reaching the new target before retiring the old one.

Connection lifetime is not a request timeout. Expiry does not interrupt an active request, and replacement connections are created as needed. OS DNS caches, proxies and load balancers can also affect the actual route, so this setting does not guarantee an exact cutover time.

The code shows configuration patterns, not complete application bootstrapping. Share the configured client once, dispose responses after consuming their bodies, and keep request deadlines and safe retry rules as separate decisions.

The carousel includes a cutover checklist and a sustained-traffic test. A healthy replacement server is only half the evidence; the other half is proving callers actually reach it.

After a dependency changes address, what signal proves your callers have moved to the new endpoint?

The screen closes, yet its refresh callback keeps running. C # event unsubscription can silently miss a handler when cle...
11/11/2026

The screen closes, yet its refresh callback keeps running. C # event unsubscription can silently miss a handler when cleanup creates a new lambda, leaving stale work behind in a long-running app.

A common interview trap: do two lambda expressions with the same body cancel each other out with += and -=? Do not rely on that. Matching text is not a reliable delegate identity.

An event lets a publisher call subscribed handlers when something changes. In the BAD block, the two separate lambda expressions do not reliably identify the same handler, so cleanup can leave the original subscription attached.

The GOOD block assumes Changed is an EventHandler event. Store the delegate when subscribing, then pass that same value to -= during cleanup. Refresh is your refresh method. The two blocks are alternatives, not one sequence to run.

In a real class, keep handler in a field if cleanup runs in another method. A named method with the matching signature is another clear option. Keep the same publisher instance too.

My suggestion: review the subscription and its cleanup together. Retaining the delegate does not prevent duplicate subscriptions; each += adds a registration. Removing a handler also does not cancel a callback already in progress.

One useful test: subscribe, raise the event, clean up, then raise it again. Verify the callback count does not increase after cleanup. This checks behavior rather than just the presence of a -= line.

Where do you pair event subscriptions with cleanup in your .NET applications?

ASP.NET Core CSRF protection matters when a browser sends login cookies automatically. A valid session can still accompa...
10/11/2026

ASP.NET Core CSRF protection matters when a browser sends login cookies automatically. A valid session can still accompany a forged write, turning a trusted user into an unintended action.

A login cookie tells the server who the user is. It does not, by itself, prove that a state-changing browser request came through your intended application flow. CSRF means cross-site request forgery: another site tries to make that browser act on the user's behalf.

The common mistake is treating an authenticated POST as enough protection. In a cookie-authenticated MVC application, a sensitive action needs both its authorization checks and appropriate antiforgery validation.

A practical review for real projects:
- For MVC forms, generate an antiforgery token and validate it on the server. The carousel shows an explicit Razor token and ValidateAntiForgeryToken on an action. Form Tag Helpers can generate the token automatically.
- Register the MVC services with AddControllersWithViews. AddControllers alone does not enable built-in MVC antiforgery token support. Consider a default automatic validation filter as the number of actions grows.
- Keep GET requests free of business mutations. CORS is not a replacement: it controls browser response access, and some requests can still be sent without a preflight.
- Test valid login plus missing or invalid token, and assert that rejection happens before any state changes.

The examples assume an MVC controller, cookie authentication and normal routing. ApplyChange represents your application service; resource permissions and input validation are still required.

For JSON requests, configure a request-token header and send the token through your intended client flow. For Minimal APIs, use their antiforgery integration rather than copying an MVC filter attribute.

SameSite cookies, HTTPS and narrow cookie scope add protection. Antiforgery is not an XSS fix. APIs that accept only an explicitly attached bearer Authorization header have a different CSRF threat model; reassess if they also accept cookies.

What test catches a missing antiforgery check on cookie-authenticated writes in your projects?

Order price snapshots keep yesterday's purchase from changing when a catalog price is edited today. Without that boundar...
09/11/2026

Order price snapshots keep yesterday's purchase from changing when a catalog price is edited today. Without that boundary, receipts and support screens can disagree with what a customer paid.

In a .NET commerce backend, the catalog answers what a product costs now. An accepted order records what the customer agreed to buy then. Those are different facts.

The common mistake is keeping only a product reference and rebuilding old order totals from the current catalog price. An ordinary price edit can then change the receipt or support view without changing the payment.

A practical boundary for real projects:
- Price the checkout on the server. Do not trust a price supplied by the browser.
- Persist the accepted unit price, quantity and currency with the order. Keep the product ID for traceability, not as the source of historical price.
- Preserve the agreed discounts, tax, rounding decisions and final totals needed to explain the purchase. The code in the carousel shows a simplified subtotal, not a full pricing engine.
- Test the boundary: place an order, edit the catalog price, then confirm that the historical amount stays the same.

An editable cart may need repricing. Validate the quote when the customer accepts it, store the accepted version durably, and reconcile payment against that version. Later corrections should be explicit amendments with an audit trail, not silent recalculations.

The carousel includes a review checklist for the next checkout change. The same distinction helps with subscription terms and other historical business records.

Which order details do you snapshot so a later catalog edit cannot change the customer record?

A sensor reading slips past both limits, then breaks the dashboard. C # NaN validation matters because range checks alon...
09/11/2026

A sensor reading slips past both limits, then breaks the dashboard. C # NaN validation matters because range checks alone can accept a value that is not a number, leaving teams trusting invalid data.

A common interview trap: will x < 0 or x > 100 reject every invalid double? No. NaN means not a number. With NaN, both of those comparisons return false, so this rejection check lets it through.

NaN can come from calculations such as floating-point zero divided by zero. It is not the same as null or zero. This example starts with a double already in memory; it does not assume an HTTP JSON parser accepts NaN.

In the BAD block, Reject is never called. In the GOOD block, double.IsFinite rejects NaN and either infinity before the range check. Reject stands for your validation failure path; these are alternative snippets, not two checks to run together.

My suggestion: make the numeric contract explicit. For a sensor percentage that must be between 0 and 100 inclusive, require a finite value in that range. IsFinite is available in modern .NET, including .NET 5 and later.

Add tests for NaN, positive and negative infinity, both valid endpoints, and values just outside the range. Rejecting only NaN is not a substitute for domain limits. Keep invalid readings separate from legitimate zero readings rather than silently replacing them.

Which non-finite value would you add first to a sensor-input test: NaN or infinity?

Distributed locks can expire while a paused worker still holds unfinished work. When it wakes up, an old result can over...
08/11/2026

Distributed locks can expire while a paused worker still holds unfinished work. When it wakes up, an old result can overwrite a newer one. The lease timer alone cannot protect customer data.

A lease is a lock with an expiry time. It lets another worker take over if the first one disappears. It does not forcibly stop that first process.

Picture a report snapshot: worker A pauses, its lease expires, and worker B publishes a newer result. A later wakes up and writes its old snapshot. Acquiring the lock correctly did not make that final write safe.

A fencing token is an increasing number issued with each successful lock acquisition. The protected resource checks that number, not just the worker.

For this one-publication-per-lease example:
- B publishes with token 42. The database records 42 alongside the snapshot.
- A tries token 41. A conditional UPDATE rejects it because 41 is older.
- The comparison and write happen atomically, not as a read followed by an unchecked update.

The C # uses illustrative application APIs, not a lock-library SDK. The lock service must actually issue durable, strictly increasing tokens for the protected resource; a random owner ID is not a fencing token. Initialize the row and its Fence value before publication.

The SQL deliberately permits only one snapshot publication per token. A zero-row result can mean stale, already used, or missing. Do not blindly retry it as a new write. Multiple operations under one lease need a different resource protocol.

Fencing rejects an old token once the resource has accepted a newer one. It does not guarantee the snapshot contains the newest business data. Keep every write path fenced, and release locks only with an atomic owner check.

My suggestion: test the pause-and-resume timeline before relying on renewal or a longer expiry. If an external email or payment API cannot enforce your token, this database pattern does not protect that side effect; design its coordination separately.

How do you test a worker that resumes after its distributed lock has expired?

AI token budgets can look safe while one chat triggers retries, tool loops and several model calls. A short answer is no...
07/11/2026

AI token budgets can look safe while one chat triggers retries, tool loops and several model calls. A short answer is not a spending limit, and customers should not discover that on the monthly bill.

A token is a small unit of text a model processes. AI providers can charge for both the input and the generated output, using model-specific rates. One customer action can trigger several paid attempts.

The common mistake is setting a maximum answer length and calling it a budget. That leaves input history, retries and tool loops outside the spending decision.

For a .NET AI backend, my suggestion is:
- Bound input size and output length, then estimate the upper cost of each attempt using the actual model pricing. Include billable reasoning tokens and separately billed tools where applicable.
- Atomically reserve that amount in a shared tenant/workflow ledger before calling the provider. Two concurrent requests must not spend the same remaining balance.
- Settle the hold against final usage and release only the verified difference. If a call fails or usage is missing, keep an unknown record and reconcile later. A timeout does not prove that nothing was billed.

Each retry needs its own reservation. Also cap total calls and tool steps. A concurrency limit controls simultaneous work; it does not cap cumulative spending.

The carousel includes illustrative C # orchestration and a review checklist, not SDK-ready code. The budget store needs durable, idempotent settlement and failure handling. All billed calls must pass through the guard.

Provider usage fields and pricing differ. A conservative local estimate is an admission policy, not a guaranteed invoice ceiling. Compare the ledger with provider usage reports and define how unresolved holds are handled.

Which is harder in your AI backend: limiting retries, estimating input cost, or reconciling missing usage?

The customer ID looks correct, yet the lookup returns nothing. C # string immutability explains why calling Trim alone l...
07/11/2026

The customer ID looks correct, yet the lookup returns nothing. C # string immutability explains why calling Trim alone leaves spaces in place, creating avoidable failures at a product boundary.

A common interview trap: does id.Trim() change id? No. Strings are immutable: their contents cannot be changed in place. Trim returns the resulting string, and ignoring that return value leaves id unchanged.

In the card, the input has a space on either side of A42. Calling Trim without saving its result leaves both spaces in id. Assign the result to normalized, then pass normalized to the lookup.

This also matters with Replace and other string methods. Returning a value is not the same as updating the variable you called the method on. When no trimming is needed, Trim may return the original instance; the rule is still to use the result.

My suggestion: normalize customer IDs once at the input boundary, but only when the contract says surrounding whitespace is insignificant. Validate missing or null input separately; this tiny example assumes a non-null string.

Test the padded value, the already-clean value, and a whitespace-only input. Trimming alone is not validation. Do not apply this as a blanket cleanup rule to passwords, signatures, or other exact-match data.

Where do you normalize customer IDs in your code: at the input boundary or inside each lookup?

Docker image tags can point to different builds over time. A rollback that pulls the same tag may not restore the tested...
06/11/2026

Docker image tags can point to different builds over time. A rollback that pulls the same tag may not restore the tested release, leaving your team debugging code it did not mean to deploy.

For containerized .NET services, a tag is a readable label. Unless your registry prevents changes, a later push can move it to another build. A digest identifies specific image content instead.

The common mistake is treating a tag such as latest, or even a release version, as proof that staging and production used the same artifact.

My suggestion for real projects:
- Build once, capture the complete registry digest, and test that reference. Promote it instead of rebuilding for production.
- Have CI supply the full repository@sha256 reference. Require it in Compose and validate its format in the deployment gate. A required variable alone does not enforce digest pinning.
- Keep the previous tested image available and record the commit, platform, configuration version and schema compatibility with each release.

A multi-platform digest can identify an index of platform-specific images. Test and record the platform you deploy; the same index does not mean identical binaries on every architecture.

The carousel includes a before/after Compose example, a release receipt and a checklist for your deployment review. The references shown are illustrative, not real published images or usable digest values.

Pinning is not a security certificate. Publisher trust, provenance, scanning and deliberate patch updates still matter. Rolling back an image also does not roll back a database change.

During a rollback, how do you prove the running container matches the build you tested?

Read replica consistency can make a saved order look missing. The write succeeds, but the next request reads an older co...
05/11/2026

Read replica consistency can make a saved order look missing. The write succeeds, but the next request reads an older copy, leaving customers unsure whether to try again and support teams guessing.

A read replica is another database copy used to serve reads. It can reduce work on the primary, but a committed change may not be visible there yet. That delay is replication lag.

The common mistake is routing every GET request to the replica. Read-only describes what a request does. It does not describe how fresh the answer must be.

For an order confirmation, I would make the contract explicit:
- Return the committed order ID and status from the command instead of immediately re-reading a replica.
- Route immediate follow-up reads to the primary when the workflow needs current data. Check that a cache does not serve an older answer.
- Use replicas for reads that can tolerate delay, such as reporting. Define that tolerance with the product team.

The C # examples are illustrative repository calls, not a database SDK. SaveOrderAsync means the transaction has committed before the response. In a queued workflow, acceptance is not a completed order.

A fixed sleep does not prove a replica caught up. More advanced systems can wait for a replication position with a deadline, but that support is database-specific. Start with explicit routing and measure the primary cost.

Save the routing checklist, then test a successful write while the replica still has the old view. Duplicate-submission protection remains a separate requirement; freshness alone does not provide it.

Which screen in your product must show a write immediately, and which can tolerate a delayed copy?

Address

Dhaka
1207

Alerts

Be the first to know and let us send you an email when Dosi Bridge posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Shortcuts

Share