ESP32 webserver not replying when using static IP

I would like the ESP32 to have a static IP to access the webpage.

If the ESP32 is set to get the IP via DHCP it will get 109, then visiting 192.168.1.109 I get the reply from the webserver ("it works!").
When I set a static IP (like example below) the ESP connects to the wifi with the specified IP, but the webpage 192.168.1.80 would not load.
Obviously I made sure that the IP is available.
If I set the static IP equal to the IP that was assigned via DHCP, than the webpage loads. :o

What can I do to make it work on any static IP?

// ESP32 webserver
// 17 august 2019
// Board:ESP32 WROVER module
// stranamente funziona solo con l'ip assegnato dal DHCP. Con IP statico non carica la pagina

const char *ssid     = "xxx";
const char *password = "xxx";
#include <WiFi.h>
#include <WebServer.h>
WebServer server(80);

IPAddress ip(192, 168, 1, 80);
IPAddress gateway(192, 168, 1, 1);
IPAddress dns(192, 168, 1, 1);
IPAddress subnet(255,255,255,0);



//-------------------------------------------
void setup(){
  Serial.begin(19200);                               
  Serial.println("\n boot");
}

//---------------------------------------------------
void connect_wifi(){
  WiFi.mode(WIFI_OFF);  //serve a evitare che si metta a fare l'AccessPoint, e quindi non connettere alla rete esistente
  delay(1000);
  WiFi.mode(WIFI_STA);  //serve a evitare che si metta a fare l'AccessPoint, e quindi non connettere alla rete esistente
  WiFi.config(ip, dns, gateway, subnet); //IP statico WiFi.config(ip, dns, gateway, subnet);
  WiFi.begin(ssid, password);   //WiFi connection
  
  
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) { //blocking code
    Serial.print(".");
    delay(500);
  }

  //If connection successful show IP address in serial monitor
  Serial.println("");
  Serial.print("Connected to ");  Serial.println(ssid);
  Serial.print("IP address: ");  Serial.println(WiFi.localIP());  //IP address assigned to your ESP

  server.on("/", handleHomepage); //Associate the handler function to the path
  server.begin(); //Start the server
  Serial.println("Server listening");
}



//************************************************************************
void loop(){
  if(WiFi.status() != WL_CONNECTED){
    connect_wifi();
  }
  server.handleClient();
}
//*************************************************************


//--------------------------------------------------------------
void handleHomepage() {
  Serial.println("visit to homepage");
  String msg;
  msg="it works!";
  server.send(200, "text/html", msg); //Send web page
} //end of handleHomepage

bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);

whoho! it works!

IPAddress ip(192, 168, 1, 90);
IPAddress gateway(192, 168, 1, 1);
IPAddress dns(192, 168, 1, 1);
IPAddress subnet(255,255,255,0);
IPAddress dns1 = (uint32_t)0x00000000;
IPAddress dns2 = (uint32_t)0x00000000;
 WiFi.config(ip, gateway, subnet, dns1, dns2); //IP statico WiFi.config(ip, dns, gateway, subnet);

It seems that this is the wrong documentation

Where do I find the definition of the fuction WiFi.config? (where is the file WiFi.h?)

ingdemurtas:
It seems that this is the wrong documentation
WiFi - Arduino Reference

Where do I find the definition of the fuction WiFi.config? (where is the file WiFi.h?)

esp32 arduino core doesn't have documentation.
WiFi.h is on your computer in bards packages installation folder. it is the same folder IDE shows in Preferences as the preferences file location.
and then esp32/hardware/esp32/1.0.1/libraries/WiFi/src/WiFi.h

This didn't helped me.

My Solution is this one:

#include <WiFi.h>

const char* ssid     = "yourSSID";
const char* password = "yourPWD";

IPAddress local_IP(192, 168, 1, 139);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(8, 8, 8, 8);

void setup()
{
  Serial.begin(115200);



  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  
  if (!WiFi.config(local_IP, gateway, subnet, primaryDNS)) { //just one DNS and Configuration after connect
    Serial.println("STA Failed to configure");
  }
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected!");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("ESP Mac Address: ");
  Serial.println(WiFi.macAddress());
  Serial.print("Subnet Mask: ");
  Serial.println(WiFi.subnetMask());
  Serial.print("Gateway IP: ");
  Serial.println(WiFi.gatewayIP());
  Serial.print("DNS: ");
  Serial.println(WiFi.dnsIP());
}

void loop()
{

}