I’ve built a small web application using .Net 7. It works locally fine with https://127.0.0.1:1234 or https://localhost:1234.
It uses the GET/POST-api calls to get data from other computers and send to a database. So I want it able to be connect by other devcies in the same network. When i change it with my real local IP, like https://192.168.1.1.1:9111, it doesn’t work anymore.
Here is my code.
Did i miss anything?
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.UseCors(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
app.Run("https://192.168.1.1.1:9111");
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}