Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda