1

After Visual studio released Dev tunnels for easy debugging of e.g. localhost apis triggered from app running on real device, they made the whole mobile/webhook debugging experience better.

In .ASP NET Core you can use: Environment.GetEnvironmentVariable("VS_TUNNEL_URL") to automatically detect if you have DevTunnel turned on.

But is there a way how to auto-detect it from MAUI application ?

Because right now I had to create manual bool variable IsLocalVsTunnelTurnedOn based on which I choose the destination domain. Or is there another better way how to do this ?

Kebechet
  • 1,461
  • 15
  • 31
  • Is your peoject a maui blazor project? I created a new maui blazor project and the `Environment.GetEnvironmentVariable` can run in it. – Liyun Zhang - MSFT May 03 '23 at 07:14
  • Yes, I use MAUI Hybrid (Blazor). The command `Environment.GetEnvironmentVariable` can run there, but the environment value for `VS_TUNNEL_URL` is not set as on the server. I think this is expected but I just wanted to know if there is a way how to auto-detect it. Because currently I have: ```#if DEBUG Environment.SetEnvironmentVariable("VS_TUNNEL_URL", "https://aaaaaa-5100.devtunnels.ms/"); #endif``` at the beginning and I either comment or uncomment it to connect to dev-tunnel. Btw I call the GetEnv in `MauiProgram.CreateMauiApp` – Kebechet May 04 '23 at 14:45
  • 1
    This may be the limit in the maui. The offical blog about the Dev tunnel doesn't mention maui. – Liyun Zhang - MSFT May 08 '23 at 10:03

0 Answers0