0

How do I get the Dev Tunnel URL from the HttpContext?

I usually got the host address like this:

var host = HttpContext.Request.Host;

But when I am using a Dev Tunnel I was expecting to get that funky URL they provide you, but I still get localhost. Please help?

spmoolman
  • 403
  • 8
  • 20
  • 1
    You get what the server returned in the request/response which is at application layer. The tunnel is at the routing layer. You can only get the tunnel IP if it is a remote endpoint in the TCP transport layer. – jdweng Apr 14 '23 at 13:54
  • Thanks @jdweng I will find a different way to test – spmoolman Apr 17 '23 at 06:15

1 Answers1

1

Assuming that you are using dev tunnels in Visual Studio, you can use the Environment Variable VS_TUNNEL_URL. More info at https://learn.microsoft.com/en-us/aspnet/core/test/dev-tunnels?view=aspnetcore-7.0#tunnel-url-environment-variables

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178