【问题标题】:Error - 403 Forbidden - Microsoft-Azure-Application-Gateway/v2错误 - 403 禁止 - Microsoft-Azure-Application-Gateway/v2
【发布时间】:2021-06-23 12:48:43
【问题描述】:

当我尝试将以下请求发送到 .net core web api 时,我收到错误为“403 Forbidden - Microsoft-Azure-Application-Gateway/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": "&lt;p&gt;The retention file MXMT generation for the &quot;&lt;&lt;EngagementName&gt;&gt;&quot; did not complete successfully.&lt;p&gt;&lt;p&gt;Please contact your local country helpdesk  support function.&lt;p&gt;&lt;hr&gt;&lt;i&gt;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 时,它可以正常工作,但不能在 Service Fabric 节点上工作。

如有任何帮助,将不胜感激。

【问题讨论】:

    标签: c# .net azure asp.net-web-api asp.net-core-webapi


    【解决方案1】:

    请求正在被服务前面的 Azure 应用程序网关停止。

    https://docs.microsoft.com/en-us/azure/application-gateway/overview

    Azure 应用程序网关包括防火墙 (WAF)

    问题可能是 WAF 将您的请求标记为恶意请求。您需要首先检查防火墙上的日志以了解其被阻止的原因,然后禁用阻止请求的规则,或创建例外规则以允许该特定 url 通过。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-24
      • 1970-01-01
      • 2016-06-02
      • 1970-01-01
      相关资源
      最近更新 更多