It was in Union-occupied Alexandria in 1863 that Pvt. Henry Vanderwater, a member of the 1st District of Columbia Volunteers stationed there to defend Washington, got himself in trouble. He gave a military roster to a local newspaper, which promptly printed it. For the offense of aiding the enemy — the roster would indicate how well or poorly the town was protected — he faced a court-martial, was found guilty and received a sentence of three months hard labor and a dishonorable discharge.

Vanderwater’s court-martial would have remained a minor and forgotten piece of history if prosecutors in the court-martial of Pfc. Bradley Manning hadn’t cited the case during pre-trial hearings this past week. Manning is charged with indirectly aiding the enemy. While on active duty in Baghdad, he allegedly sent thousands of military records to the whistle-blowing Web site WikiLeaks, which then published them, giving the world, including al-Qaeda, access to the material.

The Vanderwater case, among others, was an example of military courts having already recognized that the publication of information in a newspaper can indirectly aid the enemy, government lawyers said. The defense disagreed.

The discussion about Vanderwater and his court-martial is a reminder of Alexandria’s unusual role in the Civil War. Seized by Federal troops shortly after Virginia voted to secede from the Union, it was the only city in the country to be occupied for the entire war. As longtime residents fled, the military turned public buildings, churches and private homes into barracks and hospitals. Its port and railroad connection made it an ideal military depot.

Thousands of soldiers like Vanderwater were stationed there, and thousands more passed through en route to somewhere else. The once quaint town became a very rough place.

More than 70 brothels opened for business, and local bars were always packed. A northern businessman even opened a brewery near the waterfront to fill the huge demand for beer.

According to Mark Zoeter, library assistant in the special collections section of the Alexandria City Library, about a third of Alexandria’s 12,500 residents remained in the city during the war. For them, there were the daily challenges of negotiating streets filled with drunken soldiers, having to get a pass from the military to go almost anywhere and being told to stay home after dark. By 1863, the city’s population had swelled to about 18,000 as newly freed slaves and business entrepreneurs flooded in, Zoeter said.

Alexandria is one of many Virginia towns and cities commemorating the war with special events, programs and exhibits. “Occupied City: Life in Civil War Virginia,” an exhibition at Alexandria’s history museum, the Lyceum, lets the people who lived in the city during the conflict tell their own stories through letters and diaries, said museum director Jim Mackay. Among the treasures is a letter sent to a suspected Confederate sympathizer from the Union commander, telling him to pack up and get out. The exhibition is open through September.