asp.netwebformsasp.net-ajaxiis-10

How to fix "Uncaught SyntaxError: Unexpected token '<'" on a deployed ASP WebForms website


I have been having an issue with one of my websites where it works perfectly fine while developing, but once it gets published and deployed on IIS, the styling for ONLY the account pages doesn't render, but the functional pages do render properly.

When I have a look in the console, it lists the following errors:

Uncaught SyntaxError: Unexpected token '<' (at modernizr?v=inCVuEFe6J4Q07A0AcRsbJic_UE5MwpRMNGcOtk94TE1:3:1)

1.
2.
3. <!DOCTYPE html>
   ^
4.
5.<html lang="en">
6.<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>
Uncaught SyntaxError: Unexpected token '<' (at MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:3:1)

1.
2.
3. <!DOCTYPE html>
   ^
4.
5.<html lang="en">
6.<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>
Uncaught SyntaxError: Unexpected token '<' (at WebFormsJs?v=N8tymL9KraMLGAMFuPycfH3pXe6uUlRXdhtYv8A_jUU1:3:1)

1.
2.
3. <!DOCTYPE html>
   ^
4.
5.<html lang="en">
6.<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>
Uncaught ReferenceError: Sys is not defined at Login:61:1

Sys.WebForms.PageRequestManager._initialize('ctl00$ctl09', 'ctl01', [], [], [], 90, 'ctl00');
^^^

Of the first three errors, the page that the link takes me to shows the HTML for the login page, irrespective of if I'm looking at the login page, or any other account page, even though these pages should be showing JavaScript.

I've tried looking for a solution to this, but nothing I have found even relates to the problem I am facing.

The last error leads me to believe that AJAX isn't being loaded properly, and I have no idea why.


Solution

  • It seems like the fix to it was to add EnableCdn='true' to the <asp:ScriptManager>.

    Once I did that, I stopped receiving the errors entirely, and all my styling loaded just fine after that.