-1

I have developed application which runs on Framework 4.0. Its works fine on my local machine and IIS 7.0 but it fail to work on IIS 6.0. I am getting below error

{"Message":"An attempt was made to call the method \u0027SendMailMessage\u0027 using a GET request, which is not allowed.","StackTrace":"   at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}

I have set below property on my code behind code.

    [WebMethod]
    [ScriptMethod(UseHttpGet = false)]

my Jquery method

 setTimeout(function() {
                            $.ajax({
                            cache: false,
                            type: "POST",
                            url: "Test.aspx/TestMethod",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            async: false,
                            data: JSON.stringify({
                                "strSubmitDate": $("#txtDate").val()
                            }),
                            success: function (data) {
                                alert(data.d);
                                $("#floatingBarsG").hide();
                            },
                            error: function (xhr, ajaxOptions, thrownError) {
                                //debugger;
                                alert(xhr.responseText);

                            }
                            });
                        }, 2000);

any help appreciated...thanks in advance

emmanuel
  • 9,607
  • 10
  • 25
  • 38
Vishal
  • 1
  • 2
  • Did you tried this apporach? http://stackoverflow.com/questions/5558217/error-when-calling-a-json-webservice-from-jquery – Leandro Angelo Nov 29 '14 at 22:41
  • Thanks Angelo for response. Actually It does work correctly on my local machine. IIS7.0 when I deploy on server 2003 and II6 machine I get this error. Looks I am missing something in web.config or IIS Setting – Vishal Nov 29 '14 at 23:17
  • I tried GET method also but getting below error error: Message":"Invalid web service call, missing value for parameter: \u0027ListName\u0027." – Vishal Nov 29 '14 at 23:24
  • Sorry typo mistake read strSubmitDate instead ListName – Vishal Nov 29 '14 at 23:32
  • @Vishal , what is the value for this , $("#txtDate").val() and what is the recieving type of the same in web service ? , also for post content type should be application/***form-encoded type – Vishal Sharma Nov 30 '14 at 05:03
  • Hello Vishal $("#txtDate").val() is string. It does work with IIS7 and Server 2008 but its not working with IIS6 and Window server 2003 R2. I am stuck at this point. I don't want to move from Post to Get Type. Any help appriciated – Vishal Nov 30 '14 at 05:45
  • sorry I am new to this.. so what should be the content type for post? do I need any special setting in IIS6 – Vishal Nov 30 '14 at 05:50

1 Answers1

0

I remember walking into a similar scenario, but in my case the issue was due by the shared environment at the production host stage. Regardless if the of method was sent as POST the host was always making a redirection through GET and in the end I was always receiving a 403 because of that.

I also found it, a related bug in IIS 4 and 5. http://support.microsoft.com/kb/216493

  • thanks for reply.. I am using IIS6 and I am getting different error. I tried solution given in this link but no luck...frustrated now...thought it will be simple...is it happing because I am passing 15 parameters to this method thought Jquery.. – Vishal Nov 30 '14 at 14:40
  • now I am thinking to remove jquery and call code behind method in traditional way.. – Vishal Nov 30 '14 at 14:43