I have a razor layout like:
@using (var context = SetUpSomeContext()) { Some content here @RenderBody(); } <
The execution order is from innermost to outermost.
I would argue that using a 'context' the way you use it is not the best design - you should consider moving the setup to the controller / action filter and pass the data to the views in model.