Thursday, 31 January 2008

JavaScript errors from WebResource.axd when calling an aspx over HTTPS

I ran into a pearler the other day,

The project we're working on requires that user credentials only ever pass over https, but we don't want to run the entire (behometh) site over SSL for server performance reasons.

As soon as we called our login page (which has asp.net ajax validators etc) via SSL, we started getting the now familiar 'asp.net ajax javscript isn't here' type errors. Fiddler showed very few files being served compared to an unsecured request.

Googling kept turning up a fix revolving around the ServicePointManager (example), but it didn't seem relevant to my error... The penny finally dropped when I checked the Event Log of the server, and saw the errors mentioned on Jan Tielens blog, which also has the best treatise on why this occurs.

Using the ServicePointManager.ServerCertificateValidationCallback to return true instantly solved the issue.

Because I wasn't on the consuming side of these requests (as opposed to me making a ScriptService call), I hadn't run into the exception from the consumer side, which explains why it took so long for me to twig that this was in fact the fix I needed.

It took 2 days, but I chewed that Gristle down :)

No comments: