Call WebService - Request format is unrecognized for URL unexpectedly ending

I have jquery call an webservice.


        timeout: 10000,
        type: "POST",
        url: "AgentService.asmx/GetAgentData",
        data: JSON.stringify({ agentId: agentId }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data, textStatus, xmlhttp) {

            if (data.d != null) {

                PopulateAgentData($popup, data.d);
        error: function (xmlhttp, errorMessage, exceptionObject) {

            HandlePopupError($popup, xmlhttp, errorMessage, exceptionObject);

Got following error

Request format is unrecognized for URL unexpectedly ending in /GetAgentData

I saw solution on internet

The solution in previous versions is to add this to the web.config for the protocols needed (typically omitting HttpGet for production):
      <add name="HttpGet" />
      <add name="HttpPost" />
      <add name="HttpSoap" />

I changed it.

Then, I got another exception:
System.InvalidOperationException: Request format is invalid: application/json; charset=UTF-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()


I solved it ending up running this command...
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -i
Note that you will need your command prompt in Administrator mode for it to work.

Then, IISReset  /restart

Then, reboot Windows