2

Yes, the famous "'Sys' is undefined" Microsoft JS issue.

I've already done about 4 hours of digging and trying every suggestion I can find about it, so before you immediately call this a duplicate, here me out please.

Ultimately, this question is exactly the same as this one, but the accepted answer isn't relevant to my situation, and the OP is no longer an active member.


Background

There are about a hundred pages in this application. Each of them ultimately inherits from the same base class. This base class overrides the Init method and dynamically adds a ScriptManager to it as the first Form control.

On one single page out of them all, I encounter the issue described in the post I linked. I mentioned that the accepted answer was relevant. Here's why:

  1. I'm not making any Sys. calls
  2. My page doesn't have any AJAX-enabled controls on it
  3. My page doesn't have any JavaScript on it
  4. My web.config is accurate, it includes the proper handler entries
  5. The issue is reproducible on both IIS 6.0 and IIS 7+
  6. If I explicitly add a ScriptManager to the page via <asp:ScriptManager />, the ScriptResource.axd include still doesn't render to the output page
  7. I've tried clearing browser history, Temporary ASP.NET Files, rebooting, etc. with no change in behavior
  8. An older version of the application in our UAT environment functions correctly; the base page code nor the web.config file have changed since then

I'm completely stumped. It's an ASP.NET 3.5 web site project running on Win Server 2003 with IIS 6.0 (both Prod and UAT). My developer environment is Win7 with IIS 7.5. Same behavior in both environments.

Question

Does anybody have any ideas? I'm starting to think it's a bug in the ASP.NET 3.5.1 framework...

Community
  • 1
  • 1
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
  • Looks like a duplicate of this one http://stackoverflow.com/questions/3822733/ajaxtoolkit-iis7-asp-net-4-0-sys-is-not-defined-handler-mapping-issue OR http://stackoverflow.com/questions/75322/sys-is-undefined – HatSoft Jul 14 '12 at 19:20
  • @HatSoft: Except there's nothing missing from my web.config. – Cᴏʀʏ Jul 14 '12 at 19:21
  • have you also checked this one http://stackoverflow.com/questions/75322/sys-is-undefined – HatSoft Jul 14 '12 at 19:22
  • @HatSoft: Yes, that's the one I already linked to in my post. – Cᴏʀʏ Jul 14 '12 at 19:28
  • This is the case where the Sys. is called before the scriptManager load it. Can you on the rendered page what is calling the sys ? – Aristos Jul 14 '12 at 22:04

2 Answers2

2

I've just had a similar issue that I seem to have just resolved.

IF you are overriding any other page lifecyle events on your page other than PageLoad make sure to trigger the base version of the event. E.g. I was using OnPreRenderComplete

protected override void OnPreRenderComplete(EventArgs e)
{
    base.OnPreRenderComplete(e); //ADDING THIS LINE FIXED THE PROBLEM

    //Add THEAD etc to Gridview
    if (gvQueue.Rows.Count > 0)
    {
            gvQueue.HeaderRow.TableSection = TableRowSection.TableHeader;
    }
}
Jon P
  • 19,442
  • 8
  • 49
  • 72
0

Since you have tried everything else, and because it is reproducible, I can think of 3 possible causes that you can check:

1) The element not being defined correctly.

Make sure that the head element has runat="server" specified. We always provide an id as well, although I don't think that is strictly required:

<head id="HEAD1" runat="server">

2) The code that is causing the exception is being executed prior to the inclusion of the ScriptResource.axd.

To verify whether this is the case or not, I look at what has loaded in the page so far when the exception occurs. If I don't see the resource that is being reported as missing, I know I have an ordering problem.

I have seen this caused by two hooks of Page.Init (or other methods) in the inheritance tree and when this occurs, you cannot guarantee an order of execution.

3) An invalid page structure.

I have seen numerous cases where a misplaced, easily overlooked character, such as a single quote, double quote or < silently wrecks the page or javascript structure.

To verify that this is not the case, I first validate the page in design mode (Edit, Advanced, Validate Document) and correct any errors.

If there are no errors in design mode, I validate the rendered page by copying the source of the rendered page into an empty page within the project and then validating. This process has caught more than one subtle issue in the page structure.

4) If none of the above solve the problem, there could be an issue with the framework. If there is, it could possibly be caused by element names or order in your page. You can try removing or reordering items in your page until the problem goes away.

Hope this helps.

competent_tech
  • 44,465
  • 11
  • 90
  • 113