A customer reports that your "create order" form stopped working after the last release. No error, no 500 — the order just saves blank. You cannot reproduce it: on your machine the form binds perfectly. The difference is that the deployed binary went through obfuscation and yours did not, and somewhere between the browser and your action method a property name changed out from under the model binder.

This is the most quietly destructive obfuscation break in ASP.NET Core, and it has nothing to do with routing or reflection discovery. It is model binding: the framework fills your parameters and model properties from request data by matching a wire key to a CLR member name. Rename the member and the key the binder expects changes with it, while the browser keeps sending the old one. The request still arrives, the action still runs, the model is just empty. This is a map of exactly where that happens — route, query, form, header and JSON body — and how to freeze the HTTP contract with Nebula.NET while every model class renames underneath it.

The one thing to understand: wire key versus member name

Every bound value has two names that are normally identical and that obfuscation pulls apart. The wire key is what the client sends — a form field name, a query-string key, a JSON property, a route segment. The member name is the CLR identifier — a parameter or a property. Binding works by making them equal. Consider a plain controller action:

[HttpPost("/orders")] public IActionResult Create([FromForm] CreateOrderModel model) => ...; public sealed class CreateOrderModel { public string CustomerName { get; set; } = ""; public decimal Total { get; set; } } 

When a form posts CustomerName=Acme&Total=99.50, the framework builds a ComplexObjectModelBinder for CreateOrderModel and, for each property, computes the key it will read from the form collection. That key is, in effect:

string key = metadata.BinderModelName ?? metadata.PropertyName; 

With no attribute, BinderModelName is null, so the key is the property name — CustomerName. The form has a CustomerName field, they match, the value binds. A JSON body takes a parallel path through System.Text.Json, which reads PropertyInfo.Name (camel-cased by the web defaults) to match {"customerName": "Acme"}.

Now obfuscate the assembly. Renaming runs on the DLL after the C# compiler is done, and it rewrites CustomerName to a everywhere it is defined and referenced — consistently, so the code still compiles and runs. But the form still says CustomerName. The binder now computes key = "a", finds no a field in the form, and leaves the property at its default. model.CustomerName is "", model.Total is 0. No exception; [ApiController] validation sees a non-null model and may not even 400. The order saves blank.

Where binding reads a name — the full surface

The trap is the same shape across every binding source; only the collection the key is looked up in changes.

  • Route tokens. [HttpGet("orders/{id}")] binds {id} to a parameter named id, or to a property with BinderModelName == "id". If you use the conventional [Route("[controller]/[action]")] tokens, the URL itself is also built from the type and method names — a separate break covered in the app-wide post; prefer literal templates.
  • Query and form. [FromQuery] int page reads ?page=; [FromForm] CreateOrderModel reads each property name from the form. Both use BinderModelName ?? PropertyName.
  • Header. [FromHeader] string xApiVersion reads the header whose name is the parameter name — and HTTP header names with hyphens never match a C# identifier, so these almost always need an explicit name regardless of obfuscation.
  • JSON body. [FromBody] CreateOrderModel is deserialized by System.Text.Json (or Newtonsoft), which matches JSON property names to PropertyInfo.Name. This is the same contract the System.Text.Json post covers, and [JsonPropertyName] is the pin.

Every one of these keys defaults to a CLR name that obfuscation rewrites. The fix is identical in each case: move the key off the member name and into a string literal.

Pinning the contract

The robust move is to put the wire key in an attribute on every bound member. The attribute's Name is a string literal; string encryption reproduces it at runtime and renaming never touches a literal. The member underneath is then free to rename.

public sealed class CreateOrderModel { [FromForm(Name = "customerName")] public string CustomerName { get; set; } = ""; [FromForm(Name = "total")] public decimal Total { get; set; } } 

The same Name = exists on [FromQuery], [FromRoute], [FromHeader] and the general [ModelBinder(Name = "...")]. For a top-level parameter it reads the same way:

[HttpGet("orders/{id}")] public Task<IActionResult> Get( [FromRoute(Name = "id")] int id, [FromQuery(Name = "detail")] bool detail) => ...; 

Razor Pages bind to properties on the PageModel marked [BindProperty], which also carries a name:

public sealed class CreateModel : PageModel { [BindProperty(Name = "customerName")] public string CustomerName { get; set; } = ""; } 

Minimal APIs that group parameters into a struct with [AsParameters] bind each public property exactly like a top-level parameter — by property name — so pin them the same way:

struct SearchArgs { [FromQuery(Name = "page")] public int Page { get; init; } [FromQuery(Name = "customer")] public string? Customer { get; init; } } app.MapGet("/orders/search", ([AsParameters] SearchArgs a, IOrderService svc) => svc.SearchAsync(a.Page, a.Customer)); 

The [Bind] surface cuts the other way

[Bind] and BindNever are allow/deny lists that reference property names as strings, and they interact with renaming in a way worth calling out. [Bind("CustomerName,Total")] on a parameter is an over-posting guard: only those properties bind. The string list is matched against property names, so after renaming the list says CustomerName and the properties are a and b — the guard now matches nothing and every property is effectively excluded. If you use [Bind], the properties it names are part of your wire contract and must be pinned (or kept) like any other.

[BindNever] is the happy case. A property marked [BindNever] is explicitly not read from the request:

public sealed class CreateOrderModel { [FromForm(Name = "customerName")] public string CustomerName { get; set; } = ""; [BindNever] public DateTime CreatedUtc { get; set; } // server-set, never bound } 

CreatedUtc has no wire key at all, so renaming it changes nothing. [BindNever] members are a clean signal of what is internal — they are on the right side of the line in the figure and need no pin.

A config that renames the models

With every bound member pinned by attribute, you do not need a keep rule for the contract at all — the wire keys live in encrypted string literals, not in metadata. Rename the whole web assembly and harden the interior:

{ "schemaVersion": 1, "inputs": [ "publish/Contoso.Orders.Web.dll" ], "outputDirectory": "protected", "preservePublicApi": false, "encryptStrings": true, "controlFlowObfuscation": true, "renaming": { "rules": [ { "pattern": "Contoso.Orders.*", "action": "rename" } ] } } 

If you would rather not annotate every property, the alternative is one keep rule pinning the models by name and leaving encryptStrings to protect the literals elsewhere:

{ "pattern": "Contoso.Orders.Web.Models.*", "action": "keep", "scope": "type-and-members" } 

Either works. The attribute route lets you rename the model classes too, which is why it is the better default for anything you are protecting seriously. The strongest transforms — code virtualization and whole-method encryption, both Pro features in Nebula.NET — belong on the logic the actions call into, applied to the handful of methods that are the actual product, not to the DTOs.

Verifying with a WebApplicationFactory test

Unit tests never catch this: they new the model and call the action directly, so they never run the binder against a wire payload. An integration test with WebApplicationFactory<T> does run the real binding pipeline over a real HTTP request, which is exactly the path that breaks.

public class BindingContractTests : IClassFixture<WebApplicationFactory<Program>> { private readonly HttpClient _client; public BindingContractTests(WebApplicationFactory<Program> f) => _client = f.CreateClient(); [Fact] public async Task Create_binds_form_fields_by_their_wire_names() { var form = new FormUrlEncodedContent(new Dictionary<string, string> { ["customerName"] = "Acme", // the WIRE key a client sends ["total"] = "99.50" }); var resp = await _client.PostAsync("/orders", form); var created = await resp.Content.ReadFromJsonAsync<OrderDto>(); Assert.Equal(HttpStatusCode.Created, resp.StatusCode); Assert.Equal("Acme", created!.CustomerName); // assert the VALUE bound, not the status Assert.Equal(99.50m, created.Total); } } 

The assertion that matters is on the bound value, not the status code — a blank bind returns a perfectly cheerful 201 Created with an empty customer name, so a test that only checks the status passes while the data is gone.

One honest caveat makes this real: WebApplicationFactory<Program> boots the app from the Program assembly your test project references, which is the unobfuscated build. Run as-is, the test proves your contract is correct but says nothing about the protected binary. To close the loop, point the entry-point assembly at the protected output — a small test project that references protected/Contoso.Orders.Web.dll instead of the source project — or run the same HTTP suite against the published protected app as a process in CI. Then a renamed, unpinned property fails the build instead of a customer's form.

When it still bites

Pinning the properties does not pin a [Bind] include list — that is a separate string you must keep in sync, and the safest answer is to stop using [Bind] in favour of a purpose-built input model with [BindNever] on the server-set fields. TryUpdateModelAsync with a prefix uses the same name-based keys and needs the same treatment. And a custom IModelBinder that reads bindingContext.FieldName or looks up values by a hard-coded property name is binding by a string you wrote — pin or encrypt that string like any other. The rule holds everywhere: anything the framework matches to a member name is wire-facing; anything it reaches by type or by delegate is not.

The takeaway

ASP.NET Core model binding is a name-matching engine. For every route token, query key, form field, header and JSON property it computes a bind key that defaults to the CLR member name, and obfuscation rewrites that name on the DLL — so the key the binder looks for moves while the client keeps sending the old one, and the model arrives empty with no error. Draw the line once between what is on the wire and what is internal, pin the wire side with [FromQuery(Name=)], [BindProperty(Name=)] and [JsonPropertyName] so the keys live in encrypted string literals, and let Nebula.NET rename every model class and harden the logic behind it. Then send a real payload through a WebApplicationFactory test pointed at the protected build and assert on the bound values — because the framework will not tell you a property failed to bind. It will just hand you a blank order.