Why does my iPhone keep asking me for passwords for random WiFi networks? My iPhone 3GS running iOS 5.1 (although this also happened when running 4.3) keeps interrupting whatever I do with it (I might be playing a game or browsing the Web) with a dialogue asking me to enter a password for some WiFi network the phone appears to have found in the vicinity.

It's very annoying.

In the Wi-Fi Networks settings "Ask to Join Networks" is set to "off".

Why does my iPhone do that and how can I get it to stop doing that?
That must be annoying, and you have identified the correct place that should turn the feature off, which clearly isn't working.  So it's not really a problem we can identify with as we are unlikely to be able to recreate it for start.

As with lots of this type of problem, there is no way we can help assist with identifying exactly why it's doing it, other than noting that it is likely transient behaviour and provide some possible steps to try and fix it, which veers us into the realm of off-topic answers as there is no way of knowing if this "answer" can solve it for you.

But with this in mind, I would try the following steps, in this order.


Turn Wifi Off and On.  If this does not solve it:
Turn Ask to Join Networks On and Off.  If this does not solve it:
Turn Wifi Off, turn Ask to Join Networks Off, and reboot your phone, then turn Wifi On
If none of the above solves it, I would consider connecting to iTunes, backing up your device fully, performing an OS re-install, then recovering from your backup.  This is last resort, but if none of the first 3 steps fix it, it's likely that there is some corruption of the settings for your Wifi which may only be fixed by replacing with a clean setup.