How do you get the Dev Tunnel url from the HttpContext?

385 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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