Adfa

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping

Published: 6/8/2013 2:36:51 AM

The other day I was updating an old application that was created in Visual Studio 2010 originally and later was upgraded to Visual Studio 2012. One of the changes I made was to add the <httpRuntime targetFramework="4.5" /> element to web.config. When I tested the application after the updates, I noticed the following error:

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

The error was quite self-explanatory: I needed to add a ScriptResourceMapping named "jquery". Adding the following code to Global.asax solved the problem:

protected void Application_Start()
{
   ScriptResourceDefinition srd = new ScriptResourceDefinition();
   srd.Path = "~/Scripts/jquery-1.6.2.js";
   ScriptManager.ScriptResourceMapping.AddDefinition("jquery", null, srd);
}

Got comments? Post them here!

Name:

Name is optional but recommended.

E-mail:

E-mail is optional and will not be shown in the comment. It will only be used if the comment requires me to contact you directly.

Comment:
Enter text:


Popular tags
Security (5)
IIS (4)
Troubleshooting (3)
MVC (2)
TFS 2012 (2)