Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Web.HttpException: This is an invalid script resource request

Tags:

c#

asp.net

I get this error when pushing our website to our clients production server however the page works absolutely fine on their dev / test servers. What causes this error (considering I am not using any web resources myself, though I am using the asp.net ajax toolkit).

like image 501
januszstabik Avatar asked Jul 08 '09 08:07

januszstabik


4 Answers

Can you get a full stack trace on this error? There will be one in the server event log (system or application, can't remember which)?

There are various parts of ASP.NET that use script resources, and at least two slightly obscure causes of them failing with this sort of error I can think of.

  1. believe it or not, if your dlls have embedded resources in them, and they are dated in the future this will happen (if you ever compile dlls in the UK and then immediately deploy them to US web servers you'll be well aware of this issue!). I can't remember the event log error this shows, but would know if I saw it - and it is not immediately obvious.
  2. if you have a load balancer routing requests between multiple servers without being "sticky", and your servers have different machine keys, then the request will fail because the encrypted querystring identifying the resource will not be decryptable on another server. This will cause a stack trace that includes various crypto types in it.

There are lots of other causes (such as incorrect uris, or querystrings getting corrupted as mentioned above), but having a full stack trace will help here.

like image 176
Rob Levine Avatar answered Oct 28 '22 01:10

Rob Levine


The error in the end was due to some URL re-writing that was occuring the server to which the admins hadn't told us about.! Watch out for that one

like image 43
januszstabik Avatar answered Oct 28 '22 03:10

januszstabik


I used to get this annoying error all the time. Users are indeed affected by this error. We used to get complaints of pages not loading properly. After trying many things like adding DOCTYPE the error did not go away completely. Then we tried storing all the VIEWSTATEin session. Violà no more errors. If your application has a bloated view state like ours then you will see this error in the logs. Often.

like image 35
coderman Avatar answered Oct 28 '22 01:10

coderman


If indeed you are using multiple servers try the following: Add to your web.config:

<machineKey  
validationKey="21F090935F6E49C2C797F69BBAAD8402ABD2EE0B667A8B44EA7DD4374267A75D7
               AD972A119482D15A4127461DB1DC347C1A63AE5F1CCFAACFF1B72A7F0A281B"           
decryptionKey="ABAA84D7EC4BB56D75D217CECFFB9628809BDB8BF91CFCD64568A145BE59719F"
validation="SHA1"
decryption="AES"
/>

But generate the validationKey and decryptionKey yourself using the code examples found here: http://msdn.microsoft.com/en-us/library/ms998288.aspx The above link also explains more about this solution so check it out, look for Web Farm Deployment Considerations on that page

like image 42
adinas Avatar answered Oct 28 '22 03:10

adinas