Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
C# - Port Mapping with .Net Core 5.0

Expected Outcome

I'm attempting to make an ASP.NET Core 5.0 application using Kestrel, and I would like to auto port forward the server's port.

Package

I'm currently using the OpenNat.Core package. I have also tried the regular OpenNat and the same issue arises.

Issue

When port forwarding, the program says it has mapped everything correctly and the map even shows when listing all mapped ports on my router. Yet, when I attempt to view its status via CanYouSeeMe.org it returns a timed out error, and I am unable to access the server outside the network.

What I've Tried

  1. I thought that the port mapping might have been opening after the server started, so I manually opened the port and then restarted the Kestrel server.
  2. I made sure that my router supported UPnP
    • I also have a Synology NAS that I port forward from, and it works just fine.
  3. I had a friend use ZenMap to check the port.
    • The port shows that it's filtered but not open (and no service was specified).

Code

using Open.Nat;
using System;
using System.Threading;
using System.Threading.Tasks;
...
        public static async Task OpenPort(int port, string description)
        {
            try
            {
                
                NatDiscoverer discoverer = new NatDiscoverer();
                CancellationTokenSource cts = new CancellationTokenSource(10000);
                NatDevice device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
                Mapping map = new(Protocol.Tcp, port, port, description);
                await device.CreatePortMapAsync(map);
                Console.WriteLine($"Created {map}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Nevermind my firewall was blocking the application. I was able to dynamically add a firewall rule to fix the issue.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda