【问题标题】:json webservices not work after deployed to productionjson webservices在部署到生产后不起作用
【发布时间】:2012-03-22 03:29:11
【问题描述】:

我们的生产环境是:

  1. IIS 6.0

  2. .Net 框架 4.0

  3. ASP.Net 4.0 线程池

但是,当调用生产服务器上的任何 Web 方法时,例如:

    [WebMethod(EnableSession = true)]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public void Authenticate(string usrname, string challenge)

它的反应:

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

---编辑---

我的 web.config:

  <system.web>
    <sessionState cookieless="UseCookies" mode="StateServer" timeout="20"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
        <!-- ##William#2012.03.22 ##Try Fixing: System.InvalidOperationException: Request format is invalid: application/json; charset=UTF-8 -->
        <handlers>
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </handlers>
  </system.webServer>

我很确定所有 Web 方法在我的开发主机中都能正常工作。 请多多指教。

谢谢

【问题讨论】:

    标签: asp.net iis-6 asmx asp.net-4.0


    【解决方案1】:

    请按照以下步骤操作

    WCF method returning JSON / XML objects not working

    可能对你有帮助

    感谢

    【讨论】:

      猜你喜欢
      • 2021-04-22
      • 1970-01-01
      • 2017-11-13
      • 2017-04-09
      • 1970-01-01
      • 2015-12-22
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多