I am in the process of releasing a couple of asp.net websites from development to production. Everything seems to be working fine in development, but upon the release to production we get a number of javascript errors when accessing the site. This appears to be something on the server though as this same code has been deployed to a testing server and works fine with the same clients. The server is a Windows 2008 using IIS7
Errors being thrown:
An number of syntax errors (scriptResource) - 10 of these
Error: syntax error
Source File: http://website.com/ScriptResource.axd?d=abc032_vah79hasdf87&t=123456789
Line: 3
Source Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Error the same as above but with WebResource.axd instead of ScriptResource.axd - 2 of these
and then two that seem to be the real cause?
Sys is not defined
and
WebForm_AutoFocus is not defined
----------------- Addendum --------------------
As per suggestions I looked into the ScriptResource.axd and WebResource.axd
The web application being deployed has forms authentication and re-directs to the login page if any page is referenced other than the login page. It appears that this is happening with the ScriptResource.axd and WebResource.axd (i.e. login page tries to reference those items, redirection happens so they don't get the javascript back, errors are thrown)
To that end I added "location" tags to the web.config to try and allow all users through to those items, so the login page would work (see relevant web.config sections below)
<system.web>
<authentication mode="Forms">
<forms loginUrl="login.aspx" defaultUrl="home.aspx"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
...
</system.web>
<location path="ScriptResource.axd">
<system.web>
<authorization>
<allow users="*"/>
<!-- allow all users -->
</authorization>
</system.web>
</location>
<location path="WebResource.axd">
<system.web>
<authorization>
<allow users="*"/>
<!-- allow all users -->
</authorization>
</system.web>
</location>
This unfortunatly has not solved the problem either. Is there some setting/configuration option that stops the location tag from working? We've added the same tags for pages in the application (to test) and it works on the developers machine, but not the server. It looks like if we could just get these location tags working on the server everything would work, any suggestions?
Open the full URLs of the source files (...ScriptResource.axd...) in a new browser window. You should see some JavaScript content. If not, the asp.net ajax components are not correctly installed.
indicates that the Ajax client side component is not there, the sys class can not be found.
If you are using .net 3.5 it is part of the framework and they problem should be in web.config, when using .net 2.0 you need ASP.NET AJAX 1.0, if you install this msi on the server, the files go into the GAC, the central place for .net components. You could put the single file System.Web.Extensions.dll into your bin directory without installing the msi, but you still need the correct settings in the web.config file. The site ajax.asp.net has lots of information about all this.
It sounds like you may be missing a component on the server, or that the web itself isn't configured correctly to use the ASP.NET Ajax components. Perhaps the developers used another library like the Ajax.NET Toolkit and it needs to be installed on the server?
OK there were two sections to this issue and two resolutions:
First: the Sys is undefined was occuring due to the /ScriptResource.axd and /WebResource.axd being in a section of the website that was then re-directing to the login page (forms authentication) which was then not getting the required javascript back from those files.
Second: once the tags were added to enable those items to be seen it was discovered that anonymous access was disabled and it appears that for the tags to work anonymous access must be enabled.
To debug this, I would try to use FiddlerTool and see what is the exact response of all the resources your page is trying to load (ScriptResource.axd and WebResource.axd). There could be some version conflict with assmblies in the GAC.
There are some other posts/discussions of this problem, maybe there is a solution for you:
I had this problem. The WebResource.axd could not find WebForms.js (which is embedded in System.Web.dll).
I repaired the ASP.NET xx framework installation on the server, and it worked for after that.
I had the same issue and tracked the missing WebForm_Autofocus code to an option in web.config, . When this option was removed/commented out everything work and the js script was generated for all the remaining script functions.
It seems to be a web.config issue that may require Microsoft to address. I'm using VS 2010, version 10.0.40210.1 SPIRel, with code targeting .Net 4.0. I have not figured out the underlying process that kills the JS generation when this option is active.