The HTML/JS .aspx pages in my Asp.NET WebForm application use MicrosoftAjax.js file, But some security policies disallows the use of javascript eval() function. They claim that all instances of eval can be replaced by another (hopefully safer) function.
<script src="../../Scripts/MicrosoftAjax.js"></script>
How can we replace these eval() functions with different code so that the file can surpass the security validations ?
If you're using MicrosoftAjax.js version 4.5.2, I can safely say the following probably won't break anything
The line numbers are a guide only - look for the specific code to replace
The first two are easy, single line replacements
Around line 531
Around line 662
Next one just comment out the lines as shown
Around line 830
You can completely comment or remove the next function
Around line 2448
the
get_objectmethod needs to be replacedAround line 3938
And another, simple, single line replacement
Around line 4166
I can confirm that I applied these changes to a a development testing site, and it kept working. I even applied it to the production version of the site for one sparsely used section that, for some reason specifically loads MicrosoftAjax.js (in the rest of our site using, this file is loaded as part of a common header), and nothing broke there either - I then even tried changing the global common section, and the production site didn't skip a beat.
That said, no warranties implied or given, if you break something you get to keep all pieces.