2

I'm using the new Bundling and Minification in ASP.NET 4.5 Web Forms application. UnobtrusiveValidationMode requires a jquery ScriptResourceMapping to work, but I'm registering it through the ScriptBundle config.

I'm using like this:

bundles.Add(new ScriptBundle("~/Content/Scripts").Include("~/Content/jquery-1.9.0.js"));

But this generates an error:

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).

To fixing the error, this:

ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition { Path = "~/Content/jquery-1.9.0.js" });

But I want to use Bundling and Minification to combine and minimize all application scripts (in this example I use just jquery file to be more simple). What's the best solution to this case?

MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89
19WAS85
  • 2,853
  • 1
  • 20
  • 19

1 Answers1

3

That's a solution, works with Bundle and Minification, but I don't know if is the best.

bundles.Add(new ScriptBundle("~/Content/Scripts")
    .Include("~/Content/jquery-1.9.0.js")
    .Include("..."));

ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition { Path = "~/Content/Scripts" });

ScriptResourceDefinition.Path is the same as ScriptBundle virtual path.

19WAS85
  • 2,853
  • 1
  • 20
  • 19