Mr. Cantor had won primaries in his district, which stretches from Richmond to the Washington suburbs, with as much as 79 percent of the vote, and he won the general election race for a seventh term in 2012 with 58 percent.