Azure block some requests to .NET 6 API

Simeon 1 Reputation point
2022-09-26T14:31:02.11+00:00

Hello,

I'm migrating from ASP.NET Core 2.2 to ASP.NET Core 6 on Azure. I have several modified Raspberry Pi(StratoPI) that make request every 10 seconds to .NET Core portal after some operations response back.

On localhost, everything works perfectly fine, test it with Postman, but when I publish the project to Azure, the requests stop working, but with Postman request they still working when is already published.

I use Nlog, and there are no errors.

Is there can be some firewall that added to .NET Core 6, because on .NET Core 2.2 everything is working.

My API code:  
  
[Route("api/[controller]")]  
[...ApiController]  
public class ...ApiController : ControllerBase  
{  
   private readonly ILogger<...ApiController> _logger;  
  
   public ...ApiController(ILogger<...ApiController> logger)  
   {  
       _logger = logger;  
   }  
  
   [HttpPost]  
   public string GetWithBody([FromBody] S...Get s...Get)  
   {       
   }  
}  
  

I've searched a lot of, but cannot find anything that can bring me to the solution of this.
Also catch some errors from Azure Log stream: HTTP Error 400.0 - Bad Request ... The request could not be understood by the server due to malformed syntax. which can be anything.
I think there is something that I have to add to Program.cs to unblock this request, but cannot find what can be.

I am grateful for any straw that will help me find the problem.

Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET .NET Internet of things
Developer technologies ASP.NET Other
{count} votes

1 answer

Sort by: Most helpful
  1. Simeon 1 Reputation point
    2022-10-03T09:53:56.183+00:00

    It is done! Found the problem. The whole problem was one string.

    The Safe send to the portal JSON, that contains TimeStamp which is long. This TimeStamp is never readed in the API, I don't need it, so it not appear as error in the portal as others and in the class is string, so I change from string to long and start working.

    So the conclusion .NET 6 don't convert int to string as .net core 2.2 do.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.