1

I've just enabled UnobtrusiveValidation in my webforms site using the global.asax changes:

Protected Sub Application_Start(sender As Object, e As EventArgs)
    Dim jquery As New ScriptResourceDefinition
    jquery.Path = "~/js/jquery-1.11.1.min.js"
    jquery.CdnPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
    jquery.CdnSupportsSecureConnection = True
    ScriptManager.ScriptResourceMapping.AddDefinition("jquery", jquery)
End Sub

It works great, however, I already link to Jquery in my Master page(s) manually (their inclusion order in the <head> is very important so I control this myself)

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
    //<![CDATA[ 
    window.jQuery || document.write('<script src="/js/jquery-1.11.1.min.js">\x3C/script>')
    //]]>  
</script>

My problem is that I now see duplicate requests to the JQuery file in Firebug. I read ages ago how to prevent this happening, but can no longer find the source in amongst all the search engine noise. Is there a way to remove the ScriptResourceDefinition's rendering of the Jquery file.

I removed my manual links as a test, but ASP.Net only renders the Jquery link when it needs to render validators, whereas I need it on every page.

EvilDr
  • 8,943
  • 14
  • 73
  • 133
  • 1
    I dealt with the same issue a while back. Here is the link: http://stackoverflow.com/questions/12065228/asp-net-4-5-web-forms-unobtrusive-validation-jquery-issue – John Mar 11 '15 at 18:05
  • John, you're the man! Amusingly, your very question was the one I was looking for, as it turns out I already upvoted it a long time ago! Thank you. – EvilDr Mar 11 '15 at 19:31

0 Answers0