部署到生产后,json Web服务无法正常工作

时间:2012-03-22 03:29:12

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

我们的生产环境是:

  1. IIS 6.0

  2. .Net framework 4.0

  3. ASP.Net 4.0线程池

  4. 但是,在生产服务器上调用任何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()
    

    --- --- EDIT

    我的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方法在我的开发主机中都能正常运行。 请劝告。

    由于

1 个答案:

答案 0 :(得分:0)

请按照以下步骤操作

WCF method returning JSON / XML objects not working

这可能有助于你

感谢名单