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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.