问题描述
当我尝试将以下请求发送到.Net核心Web API时,收到的错误信息为:403禁止-Microsoft-Azure-应用程序-网关/v2";。我已对encodeEmailBody属性使用了HTML编码。
Web Api代码:-
[HttpPut("UpdateEmail")]
[Produces("application/json")]
public async Task<IActionResult> UpdateEmailAsync([FromBody] EmailRequest emailRequest)
{
var result = await _businessService.UpdateEmailAsync(emailRequest);
return Ok(result);
}
请求类
public class EmailRequest
{
public Guid EmailTemplateTypeId { get; set; }
public string EncodeEmailSubject { get; set; }
public string EncodeEmailBody { get; set; }
public Guid CountryId { get; set; }
}
请求
{
"emailTemplateTypeId": "4C4B989B-769B-4999-8109-5A51199C09A8",
"encodeEmailSubject": "test",
"encodeEmailBody": "<p>The retention file MXMT generation for the "<<EngagementName>>" did not complete successfully.<p><p>Please contact your local country helpdesk support function.<p><hr><i>This is an automatically generated email. Please do not respond to this email. The mailbox is not b",
"countryId": "47E37625-ECC5-4F68-ACA6-61432787390D"
}
错误:-
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>Microsoft-Azure-Application-Gateway/v2</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
注意:当我在本地调用此API时,它工作正常,但不能在服务结构节点上工作。
任何帮助都将被删除。
推荐答案
您的服务前面的Azure应用程序网关正在停止该请求。
https://docs.microsoft.com/en-us/azure/application-gateway/overview
Azure应用程序网关包括防火墙(WAF)
问题可能是网站管家将您的请求标记为恶意。您需要首先检查防火墙上的日志以了解阻止该URL的原因,然后禁用阻止该请求的规则,或者创建允许该特定URL通过的例外规则。