I considered a couple of options. The first just involved making an AJAX call to the server and having it return a JsonResult. This is clean, but I did not want to effectively double my calls to the server.
I let it sit on the backburner for a while, and then today came up with a pretty good solution. It’s not ideal, but it works well enough for me. I created a simple HtmlHelper extension that just dumps the JSON out into a variable:
You call it from a page like so:
<%= Html.Json("foo") %> <%= Html.Json("bar", Model.Something) %>
The catch though is that it would cause more overhead, especially if the app was designed in such a way that the retrievals are expensive (ours is).
I’m still ruminating on that perfect scenario, but for now I’ll be doing it this way.