Search code examples
c#asp.nettelerik

Telerik RadAsynUpload VM293:3 Uncaught SyntaxError: Unexpected token < in JSON at position 2


I am trying to using AsyncUpload file of Telerik. In my local development machine, Windows 7 and Visual Studio 2015. I can select a file and see it uploaded properly. No error is prompt in the console of browser. However, if I run it in 2012 R2 server, the following error happens and the file cannot be uploaded.

VM293:3 Uncaught SyntaxError: Unexpected token < in JSON at position 2
    at JSON.parse (<anonymous>)
    at Function.m.parseJSON (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=AspScript_ScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ab7585254-495e-4311-9545-1f910247aca5%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3acb3d1a3e-7303-48dc-a612-61700f912203%3a16e4e7cd%3af7645509%3a22a6274a%3aed16cbdc%3a4877f69a%3a86526ba7%3a874f8ea2%3a88144a7a%3a24ee1bba%3a6d43f6d9%3ab7778d6c%3ae085fe68%3ac128760b%3a1e771326%3af46195d3%3a6b3f73b3%3a68f76a79%3a52af31a4%3a5fa37e7e%3a2a2fc429%3a92fe8ea0%3a19620875%3afa31b949%3a490a9d4e%3abd8f85e4:1505)
    at g.callback (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=AspScript_ScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ab7585254-495e-4311-9545-1f910247aca5%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3acb3d1a3e-7303-48dc-a612-61700f912203%3a16e4e7cd%3af7645509%3a22a6274a%3aed16cbdc%3a4877f69a%3a86526ba7%3a874f8ea2%3a88144a7a%3a24ee1bba%3a6d43f6d9%3ab7778d6c%3ae085fe68%3ac128760b%3a1e771326%3af46195d3%3a6b3f73b3%3a68f76a79%3a52af31a4%3a5fa37e7e%3a2a2fc429%3a92fe8ea0%3a19620875%3afa31b949%3a490a9d4e%3abd8f85e4:11452)
    at XMLHttpRequest.m (Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=AspScript_ScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ab7585254-495e-4311-9545-1f910247aca5%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3acb3d1a3e-7303-48dc-a612-61700f912203%3a16e4e7cd%3af7645509%3a22a6274a%3aed16cbdc%3a4877f69a%3a86526ba7%3a874f8ea2%3a88144a7a%3a24ee1bba%3a6d43f6d9%3ab7778d6c%3ae085fe68%3ac128760b%3a1e771326%3af46195d3%3a6b3f73b3%3a68f76a79%3a52af31a4%3a5fa37e7e%3a2a2fc429%3a92fe8ea0%3a19620875%3afa31b949%3a490a9d4e%3abd8f85e4:11563)

When I clicked in VM293. The following content is shown, it seems the json.parse is trying to parse html and make the upload file fails.


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>
    iESG
</title><link href="css/bootstrap.min.css" rel="stylesheet" /><link href="font-awesome/css/font-awesome.css" rel="stylesheet" /><link href="css/animate.css" rel="stylesheet" /><link href="css/style.css" rel="stylesheet" /></head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen animated fadeInDown">
        <div>
            <div>
                <img src="images/logo.png" width="300" height="198" />
            </div>
            <h3><span id="uiAccessDeniedLabel">Error Occurred</span></h3>
            <a href="#" onclick="window.history.go(-2);">Back</a>
            <p class="m-t"> <small><span id="uiCopyrightStatement"></span></p>
            <small><a id="uiTerms">Terms</a></small> | <small><a id="uiPrivacy">Privacy</a></small>
        </div>
    </div>
    <script src="js/jquery-2.1.1.js"></script>
    <script src="js/bootstrap.min.js"></script>

</body>
</html>

Solution

  • please check your Web.config file. Here is a working snippet example.

    <configuration>
        <system.web>
            <httpRuntime maxRequestLength="2147483640"/>
        </system.web>
        <system.web.extensions>
            <scripting>
                <webServices>
                    <jsonSerialization maxJsonLength="2147483640"/>
                </webServices>
            </scripting>
        </system.web.extensions>
    </configuration>
    

    Make sure you give access to IIS User in upload folder:

    https://www.kbpublisher.com/kb/setting-up-folder-permissions-in-internet-information-services-(iis)_392.html