The majority of gnats and flies are attracted to certain smells, especially fruit and sweet scents. Many species of gnats and flies are attracted by body heat. Others are in search of moisture. Not only are they drawn to perspiration, but also the mucous around your eyes and nose that can be a source of moisture.
If you prefer, you can put the solution in a jar, and punch some small holes in the jar lid. Repellents: DEET, citronella, vanilla, pine oil, and dryer sheets are commonly used to repel gnats. You can also use fans on your porch to keep the air moving and discourage hovering swarms.