问题
The header "Abp.TenantId" is null because of the ".".
If remove the "." (like "AbpTenantId"), it will be ok.
How to add a header with a "."?
=======================================================
localhost debug:
- Provisional headers are shown (show this on client request)
- Request.Headers.Unknown (show this in server, api action)
- Request.Headers.MaybeUnknown (show this in server, api action)
localhost is ok.
The same code in server, but server error.
The code for the tenantId:
The logs have no tenantId, so error:
localhost is ok:
Server fail:
回答1:
Nginx as a reverse proxy will not pass headers that contain a period.
ABP 4.4+
TenantIdResolveKey is configurable:
Configuration.MultiTenancy.TenantIdResolveKey = "Abp-TenantId";
Below ABP 4.4
You can turn off ignore "invalid" headers in Nginx:
Syntax: ignore_invalid_headers on | off; Default: ignore_invalid_headers on; Context: http, serverControls whether header fields with invalid names should be ignored. Valid names are composed of English letters, digits, hyphens, and possibly underscores (as controlled by the underscores_in_headers directive).
If the directive is specified on the server level, its value is only used if a server is a default one. The value specified also applies to all virtual servers listening on the same address and port.
来源:https://stackoverflow.com/questions/49783689/cannot-get-header-that-contains-a-period-from-nginx