just make sure you have weep holes for water to drain out. most people get in trouble when they try to "seal" things that are hollow or made from tubing. they seal it up just enough for water to still seep in but not be able to get out very well. THAT is worse than leaving it alone.
if you have corrosion inside the frame, it probably breaks apart (mine does) and i'd pour some rust converter inside the tubing and twist it around slowly so it coats the inside. let it dry, reassemble. use a rust converter on the outside and repaint. if your hardware (fasteners, etc) are corroding, replace them with stainless hardware
using spray foam is a bad idea...it will have a lot of gaps and small voids that will hold moisture inside
here is the rust converter i use
Gempler's Rust Converter miraculously transforms rust into a primed and paintable surface so you can restore tools, equipment and other metal objects. We match any competitor's price.
www.google.com