0

I have problem encountered in using $.getJSON because I always get error "Request format is unrecognized for URL unexpectedly ending in '/GetBranches'"

Here is my code:

$.getJSON('testWS.asmx/GetBranches', function (data, status, xhr) {
                        console.log(data);
                    });

Here is the code for the web service

[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public List<BranchesModel> GetBranches()
{
    return BranchesBLL.Instance.GetBranches();
}

What is wrong with my URL? How can I possibly fix this issue so that I can use $.getJSON function?

SHINHAN
  • 685
  • 2
  • 12
  • 28

1 Answers1

0

It seems to be you are missing the below lines in your web config.. Because by default GET & POST are disabled by ASP.NET 2.0 and above

so add these lines to your web.config and try...

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

For more info.. http://aspadvice.com/blogs/ssmith/archive/2007/09/04/FIX-Request-format-is-unrecognized-for-URL-unexpectedly-ending-in.aspx

tarzanbappa
  • 4,930
  • 22
  • 75
  • 117