In Virginia, most railroads built before the Civil War were located east of the Blue Ridge and designed to connect the Piedmont to the port cities in eastern Virginia. Crossing the Blue Ridge was a major engineering challenge. Locomotives can pull massive amounts of weight on the slick rails, but they lose most of their power when the rails are tilted uphill. On a 0.5 % grade, the track rises the height of an average stairway step (6 inches) over the distance of 1/3 of a football field (100 feet). However, a modern locomotive that can pull 1,000 tons on a flat grade can pull only 200 tons on a 0.5% grade.1
In the Shenandoah Valley, most railroad construction occurred after the Civil War, and at that time the railroad companies were connecting the valley to Baltimore and Pennsylvania rather than to Alexandria or Richmond.
The lower valley got its first railroad connection in 1834 when the Baltimore and Ohio Railroad (B&O) reached Harpers Ferry. The Winchester & Potomac Railroad connected Winchester to the B&O in 1836, but a connection further south ("up the valley") was not built until after the Civil War. In 1867, the Winchester & Strasburg Railroad finally connected Harpers Ferry to the rail line stretching south to Harrisonburg.
Why the delay, when the heavy traffic along the Valley Pike clearly justified further extension of the railroad south of Winchester? The Virginia General Assembly, which had the sole authority to issue railroad charters in the state, did not want Shenandoah Valley products to be shipped by the B&O to Baltimore. Merchants in Alexandria and Richmond benefitted from Shenandoah Valley trade, and were able to deter construction of a transportation system that would hurt their economic interests.
The Board of Public Works - a government body funded by Virginia taxpayers to purchase up to 60% of the stock of new railroads, canals, and turnpikes - was not inclined to invest in new railroads that would benefit non-Virginia businesses. Eastern Virginia was politically dominant, and its elected leaders were able to restrict the economic outlets for Shenandoah Valley products until after the Civil War.
Prior to the Civil War, the Commonwealth of Virginia was willing to invest in railroads that connected the Shenandoah Valley to the Fall Line. The Manassas Gap Railroad connected the middle of the Shenandoah Valley to Alexandria, while the Virginia Central railroad connected the upper valley to Richmond. The result was an inefficient transportation system for the farmers and iron furnaces in the Shenandoah Valley, but the economit benefits of trade were concentrated in Virginia and "leakage" of profits to Maryland and Pennsylvania was limited.
During Reconstruction, however, northern companies were able to get railroad charters and ultimately build a railroad line through the valley that connected Pennsylvania with Tennessee/North Carolina.
Note that the Shenandoah Valley Railroad was built east of Massanutten Mountain, along the route of modern-day US 340 rather than Interstate 81. Going east of Massanutten Mountain enabled the railroad to transport the heavy loads from the Shenandoah Iron Works at Milnes. (The town was renamed "Shenandoah" in 1890. Waynesboro is shown as "Basic City" on earlier maps, and Roanoke was shown as "Big Lick.") The route was determined by William Milnes, who owned the iron furnaces. He built the Big Gem furnace in 1882, once the railroad reduced transportation costs.