private static int GetCurrentStatus(object xmlHttpRequest)
        {
#if BRIDGE || CSHTML5BLAZOR
            return(Convert.ToInt32(Interop.ExecuteJavaScript("$0.status", xmlHttpRequest)));
#else
            throw new InvalidOperationException(); //We should never arrive here.
#endif
        }
        private static string GetResult(object xmlHttpRequest)
        {
#if BRIDGE || CSHTML5BLAZOR
            return(Convert.ToString(Interop.ExecuteJavaScript("$0.responseText", xmlHttpRequest)));
#else
            throw new InvalidOperationException(); //We should never arrive here.
#endif
        }
        internal static dynamic GetWebRequest()
        {
#if BRIDGE || CSHTML5BLAZOR
            return(Interop.ExecuteJavaScript("new XMLHttpRequest()"));
#else
            throw new InvalidOperationException();//we should never arrive here
#endif
        }
        private static bool GetIsFileProtocol()
        {
#if BRIDGE || CSHTML5BLAZOR
            return(Convert.ToBoolean(Interop.ExecuteJavaScript(@"(document.location.protocol === ""file:"")")));
#else
            throw new InvalidOperationException();//we should never arrive here
#endif
        }
        internal static void SendRequest(object xmlHttpRequest, string address, string method, bool isAsync, string body)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("$0.send($1)", xmlHttpRequest, body);
#endif
        }
        internal static void ConsoleLog_JSOnly(string message)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("console.log($0);", message);
#endif
        }
        internal static void SetErrorCallback(object xmlHttpRequest, Action <object> OnError)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("$0.onerror = $1", xmlHttpRequest, OnError);
#endif
        }
        private static void EnableCookies(object xmlHttpRequest, bool value)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("$0.withCredentials = $1", xmlHttpRequest, value);
#endif
        }
        private static void CreateRequest(object xmlHttpRequest, string address, string method, bool isAsync)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("$0.open($1, $2, $3)", xmlHttpRequest, method, address, isAsync);
#endif
        }
        [Template("{xmlHttpRequest}.onloadend = {OnDownloadStatusCompleted}")] // Note: we  register to the loadend event instead of the load event because the load event is only fired when the request is SUCCESSFULLY completed, while the loadend is triggered after errors and abortions as well. This allows us to handle the error cases in the callback of asynchronous calls.
#endif

        internal static void SetCallbackMethod(object xmlHttpRequest, Action OnDownloadStatusCompleted)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("$0.onloadend = $1", xmlHttpRequest, OnDownloadStatusCompleted);
#endif
        }
        private static void SetRequestHeader(object xmlHttpRequest, string key, string header)
        {
#if BRIDGE || CSHTML5BLAZOR
            Interop.ExecuteJavaScript("$0.setRequestHeader($1, $2)", xmlHttpRequest, key, header);
#endif
        }