I have a pretty intensive call to a Child Action, with a massive amount of c# code simply called in a few views by:
@Html.RenderPartial("mychildAction")
Now I need to load some javascript file whenever this action is called. I can not put the tags inline (inside the view) because Jquery (and other JS libraries) aren't loaded until the end of the html page.
The (master) _layout should be aware that this ChildAction was called. But it isn't because a Child Action gets a new HttpContext.
The only solution I came up with, is to switch to a partial (including a big chunk of c# code into the partial and add a few strings to some custom object kept in the HttpContext.Current.Items and make my _Layout act appropriatly). But doing so would mean I have no output caching on this ChildAction and I throw in bad practices like code in partials.
What is the best way to handle this scenario?