Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Can you confirm that after the user has logged on, Ajax works on the remaining pages? In your initial question it sounded like a general problem and not one just one the login page. –  Peter Hahndorf Jul 4 '09 at 4:19
    
once a user has logged on everything works fine as the link through to the javascript (ScriptResource/WebResource) function (i.e. since they are logged in those requests do not get re-directed to the login page) ... the "location tag" works locally, but seems to be having issues on the live server. –  ChrisHDog Jul 5 '09 at 23:31

6 Answers 6

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.

Sys is not defined

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.

share|improve this answer
    
Pointed to the full URLs of the source files and got javascript back, so that looks good. We are using .net 3.5 SP1 and have the ajaktoolkit.dll in the bin directory and referenced in the web.config. Still no luck though. –  ChrisHDog Jul 3 '09 at 4:11
2  
I would open the page in page in Firefox with the Firebug extension installed. Select the script tab and set a breakpoint (click to the left of the line number) on the line where sys is used. Reload the page. Hover over sys, it should be an object, in your case it is likely to not be one. Check the Net tab for any broken files. I assume Firebug should show an error somewhere on the page. It may be helpful to compare the Firebug output with the same one on the Dev server where the page works. –  Peter Hahndorf Jul 3 '09 at 4:43

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?

share|improve this answer
    
The AjaxToolkit.dll is in the website's bin directory. My understanding is that (plus the web.config file) should be enough. How do you mean "installed on the server"? Is there some added installation that would need to be done? My understanding was no. –  ChrisHDog Jul 3 '09 at 0:08
up vote 1 down vote accepted

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.

share|improve this answer

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:

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.