Friday, June 22, 2012

Fix “Invalid character” error from ScriptResource.axd

Some time ago on one of our projects customers faced with the following problem: 2 users couldn’t use functionality which was implemented with javascript. For all other users everything worked, but for these 2 users it didn’t work. We checked their browsers – they used IE8. Most of other users used IE9. The first thing we tried is to run site in IE9 with IE8 browser mode and document mode (you can change it from developer tools in IE). But it didn’t give result – we couldn’t reproduce problem locally. Then I asked to send us screenshots of the pages with broken functionality and noticed that there was javascript error icon in status bar. Customers send us description of the error:

   1: User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0;
   2: SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729;
   3: Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
   4: Timestamp: Thu, 22 Jun 2012 09:00:00 UTC 
   6: Message: Invalid character
   7: Line: 1
   8: Char: 1
   9: Code: 0
  10: URI: 
  11: Message: 'Sys' is undefined
  12: Line: 148
  13: Char: 1
  14: Code: 0
  15: URI:
  17: Message: 'Type' is undefined
  18: Line: 2
  19: Char: 1
  20: Code: 0
  21: URI:
  23: Message: Object doesn't support this property or method
  24: Line: 2
  25: Char: 132
  26: Code: 0
  27: URI:

(there were more similar errors, I copied only distinct). After brief investigation and googling I found that some time this error can be fixed by disabling script compression. It can be done by adding the following line into web.config:

   1: <system.web.extensions>
   2:   <scripting>
   3:     <scriptResourceHandler enableCompression="false" enableCaching="true" />
   4:     ...
   5:   </scripting>
   6: </system.web.extensions>

And it helped. After I added this line into web.configs on all WFEs error disappeared. Users with other browsers also still work without problems. Hope it will help you if you will encounter with similar problem.

Update 2012-06-27: another way to fix this problem is to add site to the Local Intranet zone in IE settings. After that functionality also worked without problems even after we removed scriptResourceHandler from web.config.


  1. Thanks. Your post helped me. I found so many post related to my problem. But no one worked for me. This really helped me.


  2. I had this issue on some PC's but not others and was convinced there must be a client fix. I deleted all local content from IE, reset all the setting back to default but nothing seemed to fix it. I then hit the refresh button to try fix and unbelievably the refreshed fixed the issues.

    It would be interesting to see if this fixed it for other people.

  3. Thanks you so much, i had same problem like you mentioned above, i used your solution and it works ...

    let me inform you one thing in my case code was runing fine in Mozila firfox

  4. Thanks you , This article was helpful for me ~

  5. LOVE YOU, totally resolved this issue for me.

  6. I know I sound like a total idiot, which I am with this new computer/operating system. But how do I get to web.config on windows 8? I absolutely detest windows 8!!

  7. Sindii,
    web.config is located in the virtual folder of your site, which is by default is located in c:\inetpub\wwwroot\wss\yoursitename folder.