1

I have a big Javascript file generated dynamically from a method in a Controller.

public ActionResult GetEditingContext()
{
    string json = JsonConvert.SerializeObject(...);

    return JavaScript(json);
}

The javascript is almost always the same, but the user can change settings in the admin panel and the javascript should be updated. I thought that a ScriptBundle would be perfect to handle that. It would automatically check if the content has changed and update the url for the script.

The problem is that I don't know how to include a URL in a bundle.

I tried this :

bundles.Add(new TsBundle("~/bundles/editContext").Include(
            "~/Invoice/GetEditingContext"));

But the generated script bundle is empty, and has no hash. If I remove the ~ I get an exeption (Only application relative URLs (~/url) are allowed.)

Stephane Mathis
  • 6,542
  • 6
  • 43
  • 69
  • Does this help? https://stackoverflow.com/questions/19650541/how-to-add-bundles-with-dynamic-content-to-asp-net-web-optimization – RikRak Jun 26 '19 at 08:42

0 Answers0