问题描述
头 "Abp.TenantId"
是 null
因为 "."
.
如果去掉"."
(比如"AbpTenantId"
),就可以了.
如何添加带有"."
的标题?
======================================================
localhost
调试:
- 显示临时标头(根据客户请求显示)
- Request.Headers.Unknown(在服务器、api 操作中显示)
- Request.Headers.MaybeUnknown(在服务器、api 操作中显示)
localhost
没问题.
服务器中的相同代码,但服务器错误.
tenantId
的代码:
日志没有tenantId
,所以报错:
localhost
没问题:
服务器故障:
ABP 4.4+
TenantIdResolveKey
是可配置的:
Configuration.MultiTenancy.TenantIdResolveKey = "Abp-TenantId";
低于 ABP 4.4
您可以在 Nginx 中关闭忽略无效"标头:
语法:ignore_invalid_headers on |离开;默认值:ignore_invalid_headers on;上下文:http、服务器
控制是否应忽略具有无效名称的标题字段.有效名称由英文字母、数字、连字符和可能的下划线组成(由 underscores_in_headers 指令控制).
如果指令是在服务器级别指定的,则仅当服务器是默认服务器时才使用其值.指定的值也适用于侦听相同地址和端口的所有虚拟服务器.
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:
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:
这篇关于无法从 NGINX 获取包含句点的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!