Question: It seems I've been seeing a lot of uses for foam on this site, from a weapon to a spaceship defense mechanism. However, the details on what the foam is made of and how it works always seem lacking to me; thus, I worry that many of these foams are just science fiction. 

My question is **is there a foam that can be used to quickly construct airtight walls solid enough to keep humans out?** I imagine using this foam on a spaceship to trap the enemy, or alternately to fix hull breaches. Perhaps there is a fast-acting variant that can be used as a grenade to immobilize enemies. As it is a foam, it could be carried around much more easily than other wall-building materials, thus I could outfit my space marines with a few cans apiece. 

So, does this foaming material exist, or is there a theoritcal way to produce it? If so, how big would the initial substance be, and how long would it take to dry/harden? 

The foam need not be activated by air; on the contrary, it would be great if it contains its own reactants, and can be activated in a vacuum. 

It need not last; it should only be functional for a minimum of a couple hours. If it breaks down after that, that's fine. 

I would like it to be as strong as possible. If it can get to concrete levels, that would be best, but as long as it's very difficult for a human to burrow through that'll work.

Answer: 
A foaming quick set epoxy grenade might work.  

Basically a weaponized, military version of this [expanding epoxy foam](http://www.prosetepoxy.com/custom_foam.html).  

Inside the grenade would be multiple chambers containing either the epoxy and the hardener.  

When the grenade triggers, a CO2 canister could cause the contents to mix and then be sprayed out in all directions through multiple nozzles. 

Foam in a vacuum seems to be [extra effective](https://www.youtube.com/watch?v=nDMySLjeyL0) as the low pressure causes the cells to expand a lot. If the epoxy was very quick setting then the cells probably wouldn't burst before it hardened.

As @j6m8 points out, the cell walls would thin during the expansion into vacuum, which cause them to cure faster. The cells on the surface would burst, but when their walls collapsed surface tension would pull them back, thickening the outer surface, making it tougher and slowing the rate that the bubbles burst.

To further weaponize it, mix a breathable or contact anesthetic into the gas mix or hardener, so that if the cells are broken open in atmosphere the anesthetic would be released and potentially knock out the target.  

In vacuum this wouldn't be effective, but the anesthetic could be switched out for something that could attack the targets suit like an acid compound, making it dangerous to attack the wall.
Dental cement

Spray a foam version of dental cement onto the assailant. Use a high-powered laser to cure it. Alternatively don't even use foam. Just spray them with the liquid and use the laser. You will cover them in a thin but incredibly hard outer shell that will immobilise them.

[Influence of argon laser curing on resin bond strength](http://www.ncbi.nlm.nih.gov/pubmed/8397985)

The main point about using lasers is (1) the ability to aim them (2) they act at a distance and (3) they cause fast setting even if the strength isn't increased.