Home > front end >  Blazor Server-side app Android and IOS mode
Blazor Server-side app Android and IOS mode

Time:03-24

I am building a Server-side Blazor web application on localhost for now.

I want to test my web app on android and IOS devices but I cannot seem to find the solution.

I have tried connecting to the same network via wifi and have my IP address with :port but doesn't work.

CodePudding user response:

You could give ngrok a go, this would allow you to map your localhost and port to a public web address.

There are a bunch of details here:

https://ngrok.com/

CodePudding user response:

I'll assume you started with a template with "Configure for https" enabled.

For https you would have to install a certificaat on your phone, not practical. So you will have to

  1. Make Kestrel listen on an outside port
  2. Configure your app for http
  3. Make a hole in the firewall

  1. In Program.cs, just before builder.Build():
builder.WebHost.UseKestrel(options =>
{
    options.ListenAnyIP(5001);
});

var app = builder.Build();  // this line is already there
  1. and to run without https:
if (!app.Environment.IsDevelopment())
{
    ...
    app.UseHsts();
    app.UseHttpsRedirection();  // move it here
}
//app.UseHttpsRedirection();  // in Debug: allow http on local network 
  1. The first time you run this, a popup will ask if you want to add a rule to the firewall. Select Yes. Normally "private networks" is enough.

Be sure to enter a http://162.xxx.xxx.xxx:5001 address in your phone, no https.

  • Related