Problem

You finished work yesterday, go home and come into the office today only to find out that the web app has certain pages that don’t work anymore for anyone. Awesome, someone screwed something up and checked it in. To top it off the error is stupidly vague as usual.

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

Wow so full of wisdom that error is. Your first instinct would be to see what knuckle head added a new jquery library or version to the app without telling anyone. I mean the word jQuery is right there in the error. To make matters worse it says something about case sensitivity.

Solution

My coworker and I wasted too much time looking into this problem thinking it was related to a new library that was introduced to the web app. We started digging through recent commits and comparing files. This was certainly a needle in a haystack situation. Finally it dawned on my coworker that all the pages that were having this stupid problem happened to be pages that have ASP Net validators on them. This wasn’t a coincidence.

We did some digging and everyone first suggests that you add a new key to your appSettings. This is a valid option, but why did the web app started acting this way suddenly? I don’t like ignoring problems with band-aids because they can come back to haunt you.

Ultimately it came down to the fact that a coworker changed the Web.config:

<system.web>
    <!-- Notice that the target framework is set to 4.6.1 -->
    <httpRuntime targetFramework="4.6.1" />
</system.web>

Our coworker explicitly set the target framework to 4.6.1 which is what caused this problem to start happening.

You have two choices to resolve this problem:

Solution 1 – add an appSettings key

This solution is all over the web, it is typically the first solution you find. Just add the following appSetting key to your Web.config and the problem will vanish as quickly as it appeared.

<appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>

However in my opinion, since we didn’t have this problem before, I wouldn’t recommend using this solution unless you are sure it won’t cause a problem for you anywhere else.

Solution 2 – change your target httpRuntime version

Make sure that your HTTP Runtime is pointed to below framework version 4.5, in my case the framework version was never specified so I removed it all together which I think by default will make it point to 4.0 but I am not entirely sure. Don’t confuse this with the actual framework version that your assemblies run off of. Our projects are all pointed to 4.6.1 – these are two different things. Eventually we will want to fix our HTTP Runtime, but not right before a release.

This under appreciated answer was found here: https://stackoverflow.com/a/39190583/603807

Resources

Leave a Reply

Your email address will not be published. Required fields are marked *