You seal off the area days ahead of time and search everyone going in.
seal off what area? the whole city? 26 miles of boston on either side of the streets for days ahead of time, shutting down the whole city since the route bisects much of the city?
The only lapse i can see might be that they didn't have enough bomb sniffing dogs, but bomb sniffing dogs are trained mostly on C-4 and dynamite analogs... if the bombs were very crude, they might have been made from household chemicals and may not have even caused specialized canine sniffers to alert. But locking down a whole city for days ahead of time with a "search of everyone going in"? Not likely, in my opinion.