Getting JavaScript runtime error: irrationalPath,

2019-07-08 19:41发布

问题:

In my MasterPage i'm using the following script

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

And in my application, i have this peace of JavaScript code

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

I also have the Application_AcquireRequestState method below

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)
        {

        }
    }

When document.getElementById(menu_number).src = "<%=HttpContext.Current.Request.ApplicationPath%>/UI/Common/Images/down-arrow.gif"; is being executed, it throws the below error in IE 11.

JavaScript runtime error: irrationalPath

It also throws an exception in method "Application_AcquireRequestState" but i'm not able to get the exception details. When i put a try -- catch in the method "Application_AcquireRequestState", the exception inner message being returned is

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

I'm finding it hard to debug this. The above line of JavaScript executes successfully on the initial page load but throws that error when i'm clicking particular hyperlinks after page load.

What could be the most likely causes of JavaScript error: irrationalPath? And what does "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." actually mean?

Any suggestions on how i can effectively troubleshot this?

I have already seen observed that the IrrationalPath exception is defined in the javascript file at http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.3

回答1:

The most likely cause of the JavaScript error: irrationalPath error probably has nothing to do with any of the code you posted in the question. It's a dojo error that is usually seen when there's a problem with the dojo loader. It probably has something to do with the paths or pacakges setup in dojoConfig. See here for more info.

The other error you are getting is a .NET error. I can't be certain without seeing more of your code but this Microsoft support article is a good starting place for troubleshooting that erroor



回答2:

Have you tried to make the HttpContext.Current.Request.ApplicationPath as String in your js code (delimited with two quotes).

js code become :

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