Cᴏʀʏ
Cᴏʀʏ

Reputation: 107536

'Sys' is undefined -- rendered markup is missing a reference to ScriptResource.axd

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...

Upvotes: 2

Views: 985

Answers (2)

Jon P
Jon P

Reputation: 19772

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;
    }
}

Upvotes: 2

competent_tech
competent_tech

Reputation: 44931

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.

Upvotes: 0

Related Questions