关闭

Call WebService - Request format is unrecognized for URL unexpectedly ending

349人阅读 评论(0) 收藏 举报
分类:


I have jquery call an asp.net webservice.

 

$.ajax({
        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):
<system.web>
  <webServices>
    <protocols>
      <add name="HttpGet" />
      <add name="HttpPost" />
      <add name="HttpSoap" />
    </protocols>
  </webServices>
</system.web>


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()


Finally,

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


0
0

猜你在找
【直播】机器学习&数据挖掘7周实训--韦玮
【套餐】系统集成项目管理工程师顺利通关--徐朋
【直播】3小时掌握Docker最佳实战-徐西宁
【套餐】机器学习系列套餐(算法+实战)--唐宇迪
【直播】计算机视觉原理及实战--屈教授
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之矩阵--黄博士
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之凸优化--马博士
【套餐】Javascript 设计模式实战--曾亮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1072353次
    • 积分:12813
    • 等级:
    • 排名:第1046名
    • 原创:118篇
    • 转载:709篇
    • 译文:0篇
    • 评论:92条
    文章存档
    最新评论