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:
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
- Make Kestrel listen on an outside port
- Configure your app for http
- Make a hole in the firewall
- In Program.cs, just before builder.Build():
builder.WebHost.UseKestrel(options =>
{
options.ListenAnyIP(5001);
});
var app = builder.Build(); // this line is already there
- 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
- 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.