Sys.ParameterCountException: Parameter count mismatch

Anyname Donotcare picture Anyname Donotcare · Jun 14, 2012 · Viewed 27.7k times · Source

I face the following problem in firefox and google chrome :

Sys.ParameterCountException: Parameter count mismatch. 

I call the following javascript method onclick :

<script type="text/javascript">
        var confirmSubmited = false;
        function SubmitWithLog(par_name, par_address, frm) {

            jQuery.ajax({
                url: "/LogAction.ashx?par_name=" + par_name + "&par_address=" + par_address,
                type: "GET",
                timeout: 3000,
                async: true, // you can try and async:false - maybe is better for you
                data: action = 4, // here you send the log informations
                cache: false,
                success: function(html) {
                    jQuery(frm).submit();
                },
                error: function(responseText, textStatus, XMLHttpRequest) {
                    jQuery(frm).submit();
                }
            });

            return false;
        }
    </script>

The link from firebug will render like this :

<a href="#" onclick="SubmitWithLog('%d8%b7%d9%84%d8%a8+%d8%a5%d9%84%d8%aa%d9%85%d8%a7%d8%b3+‌​%d9%84%d9%84%d9%85%d9%88%d8%a7%d8%b1%d8%af+%d8%a7%d9%84%d8%a8%d8%b4%d8%b1%d9%8a%d‌​8%a9','...../RequestList.aspx','#ctl43');return false;">GO </a>

according to the following link :

Error: Sys.ParameterCountException: Parameter count mismatch.

I set the ScriptMode = "release"

but i get another error

this._toFormattedString is not a function

This problem isn't exist in IE.


EDIT :

public class LogAction : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {


        public void ProcessRequest(HttpContext con)
        {
            // log here what you wish
            string[] statistics = TrackUser();
            string a = HttpUtility.UrlDecode(con.Request.Params["Par_name"].ToString());
            string b = con.Request.Params["Par_address"].ToString();

            TraceActivity(a, b, statistics[0], statistics[1], statistics[2]);
            // end up with no content
            con.Response.TrySkipIisCustomErrors = true;
            con.Response.Status = "204 No Content";
            con.Response.StatusCode = 204;
        }

    //-------------------------------------------
    }

Answer

Vartan Arabyan picture Vartan Arabyan · Jun 25, 2012

Thats what happens when you call a public method of an ajax API with the incorrect number of parameters. For example, try Boolean.parse("true", "what?"). It only takes 1 parameter, you passed in 2 or your sending a null value.

also your submit link ...../RequestList.aspx does not look like a proper address. so make sure you are not passing null or wrong parameters.