【问题标题】:Getting JavaScript runtime error: irrationalPath, what does it mean?获取 JavaScript 运行时错误:irrationalPath,这是什么意思?
【发布时间】:2016-04-20 18:16:31
【问题描述】:

在我的 MasterPage 中,我使用以下脚本

<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.3"></script>

在我的应用程序中,我拥有这种 JavaScript 代码的平静

document.getElementById(menu_number).src = "<%=HttpContext.Current.Request.ApplicationPath%>/UI/Common/Images/down-arrow.gif";

我下面还有Application_AcquireRequestState方法

public void Application_AcquireRequestState(object sender, EventArgs e)
    {
        // Get http context from the caller.
        HttpApplication application = (HttpApplication)sender;
        HttpContext context = application.Context;

        // Check for encrypted query string
        string encryptedQueryString = context.Request.QueryString["request"];
        try
        {
            if (!string.IsNullOrEmpty(encryptedQueryString))
            {
                // Decrypt query strings
                string cryptoKey = System.Web.HttpContext.Current.Session["CryptoKey" + System.Web.HttpContext.Current.Session["UNIQUEKEY"]] == null ? HttpContext.Current.Application["CryptoKey"].ToString() : System.Web.HttpContext.Current.Session["CryptoKey" + System.Web.HttpContext.Current.Session["UNIQUEKEY"]].ToString();
                string decryptedQueryString = CryptoQueryStringHandler.DecryptQueryStrings(encryptedQueryString, cryptoKey);
                context.Server.Transfer(context.Request.AppRelativeCurrentExecutionFilePath + "?" + decryptedQueryString);
            }
        }
        catch (Exception ex)
        {

        }
    }

在执行document.getElementById(menu_number).src = "&lt;%=HttpContext.Current.Request.ApplicationPath%&gt;/UI/Common/Images/down-arrow.gif"; 时,会在 IE 11 中抛出以下错误。

JavaScript 运行时错误:irrationalPath

它还在方法“Application_AcquireRequestState”中引发异常,但我无法获取异常详细信息。当我在“Application_AcquireRequestState”方法中尝试--catch时,返回的异常内部消息是

无法评估表达式,因为代码已优化或本机框架位于调用堆栈顶部。

我发现很难调试。上面的 JavaScript 行在初始页面加载时成功执行,但是当我在页面加载后单击特定超链接时抛出该错误。

JavaScript 错误:irrationalPath 的最可能原因是什么? 而“Unable to evaluate expression because of the code is optimize or an native frame is on the call stack.”究竟是什么意思?

关于如何有效解决此问题的任何建议?

我已经观察到 IrrationalPath 异常是在 http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.3 的 javascript 文件中定义的

【问题讨论】:

    标签: javascript dojo arcgis httpcontext arcgis-js-api


    【解决方案1】:

    您是否尝试在您的 js 代码中将 HttpContext.Current.Request.ApplicationPath 设为字符串(用两个引号分隔)。

    js代码变成:

    document.getElementById(menu_number).src = <%="'"+HttpContext.Current.Request.ApplicationPath+"'"%>+"/UI/Common/Images/down-arrow.gif";
    

    【讨论】:

      【解决方案2】:

      JavaScript 错误的最可能原因:irrationalPath 错误可能与您在问题中发布的任何代码无关。这是一个 dojo 错误,通常在 dojo 加载程序出现问题时出现。它可能与 dojoConfig 中的路径或 pacakges 设置有关。请参阅here 了解更多信息。

      您遇到的另一个错误是 .NET 错误。如果没有看到您的更多代码,我无法确定,但 this Microsoft support article 是解决该错误的良好起点

      【讨论】:

      • 我已经尝试过 Server.Execute 方法,结果没有任何变化。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多