After brief investigation of “WPSC is undefined” error I found that WPSC is defined in ie55up.js script. Several people wrote that they just added this script into theirs page and error disappeared. But it was not the way for us as this script existed in resulting html source (with several other core Sharepoint scripts):
I turned on script debugging in IE8 developer tools and it showed that there were errors during loading of several of these scripts (init.js and ie55up.js). It showed “Invalid character at position 1” error. I looked on the exact response of the server and result was surprising: instead of content of .js files server returned html page with the following error message:
I.e. String.EndsWith() call inside SPRequestModule.PostAuthenticateRequestHandler() raised exception “Value cannot be null”. So initial error “WPSC is undefined” was just side effect of SPRequestModule’s failure during processing of request to ie55up.js script.
There were not much search results for this error. And no one of them contained neither the explanation of the reason nor the solution. As temporary fix people tried to change <compilation batch=”false”> on <compilation batch=”true”> in web.config located in 12/template/layouts folder – but it just expanded time between errors. I tried it also – and error really disappeared on short time but only on 1 of 2 WFEs in the farm. After several requests error occurred again (similar behavior is described for example here).
After that I decided to investigate error from other side – using Reflector. First of all I opened SPRequestModule.PostAuthenticateRequestHandler() and checked all occurrences of String.EndsWith() calls. There are only 3 calls:
As 2 calls contained constants as 1st parameter of String.EndsWith() then only one of these 3 calls could cause “Value cannot be null” exception:
So LoginUrl was null because of some reasons. There is only 1 assignement of non null value to SPRequestModule.LoginUrl variable – in SPRequestModule.EnsureInitialize() method:
I checked that FormsAuthentication.LoginUrl contains valid non null value (just traced it in simple application layout page). So the only reason of having LoginUrl non initialized was returning of null in the following call:
After looking inside SPWebApplication.Lookup() method I’ve found that it uses host headers somehow:
And now I got it – one of the configuration change was removing host headers from IIS web sites on both WFEs on farm (there were some technical reasons for this). So I recover host headers of web sites in IIS settings, remove temporary files from Temporary ASP.Net files folder and restarted IIS. After that error disappeared.
PS. This is not 1st time when Reflector greatly helped me. In one of my previous posts I described how Sharepoint sets CurrentThread.CurrentUICulture depending on Language of SPWeb. And it was investigated also with help of Reflector.