Bring a large pot of water to a rolling boil, season with 2 tablespoons salt, and blanch the green beans for 5 minutes. Shock the green beans in a bowl filled with ice water, then remove and set aside to dry.
Melt the butter in a large cast-iron pan or Dutch oven over medium-high heat. Add the shallots and cook until lightly browned. Add the mushrooms and some salt and pepper, and cook until just softened. Add the flour and stir to coat the mushrooms and shallots. Add the chicken stock, whisking vigorously to smooth out any lumps. Whisk in the half-and-half. Bring to a simmer and cook for 3 minutes. Check the seasoning and adjust with more salt and pepper as needed. Add the green beans, then pour the mixture into a 9-by-13-inch baking dish.
Bake for 30 minutes. Let the casserole rest for 5 minutes. Sprinkle with fried onions to lend some extra crunch. Serve.