I would like to spend a couple of words on this error message, which may appear in websites based on ASP.NET. In my case, I had developed a website in C#, using Ajax and Telerik, and deploying it in an IIS server on Windows Server 2016.
A day, a colleague of mine told me that it was no more possible to execute an operation
in the website. I opened Visual Studio on my local machine,
started the debugger and... It worked! Very strange, since the
live version was not working. I used Firefox to understand what
was happening, and I could learn only that the problem was
related to JavaScript. sys.webforms.res is undefined
was the message
from the Firefox console,
but it pointed me to some lines of the file MicrosoftAjax.js
”. That
file was part of the
Microsoft.AspNet.ScriptManager.MSAjax
package, so I updated it with
NuGet, but nothing changed.
I had a look on the web, but solutions were related only to configurations
of web.config
and other stuff like
that, but my environment was perfect. I even read about someone who restarted the computer (not the
server!)
to solve the issue, and this was helpful, as I am going to explain.
I decided to use Google Chrome to
investigate the issue, and Chrome returned the JavaScript error
Sys.WebForms.PageRequestManagerServerErrorException
.
I had a look on the web, no solutions, but I understood two things: the problem was hidden because I
was using AJAX;
the error could be related to the content returned after an AJAX request, content not compatible
with what the
application was expecting. So I decided to read network packages and, when I found the response to
the AJAX request
I had identified (with a 403 response code), I had a look at its preview and… it contained a message
from
the CDN I was using (in that case Cloudflare) with a captcha box
to be sure I was human and not a robot. I went to Cloudflare
admin panel and I discovered that the IP address of my company
was considered dangerous since it was making many POST requests
to that URL, so a captcha was sent as a response for that URL. Maybe the guy who solved the
issue restarting the computer had a dynamic IP address, and not a static one. I simply disabled the
CDN web
application firewall and it worked. Alternatives solution could be found, like putting the IP in the
whitelist
(if predefined IPs is sufficient to you) or I don’t know what else.
Firewall rules have to be taken into account: what about AJAX, what if I cannot see the captcha on the screen because I have written asynchronous code?