错误手札

发布时间:2024-12-16 01:16

适当放手:允许孩子犯错误,让他们在错误中学习和成长。 #生活技巧# #家庭教育建议# #家庭情感教育#

jQuery Ajax to asp.net asmx web service throws Request format is invalid: application/json

解决方案来自:stackoverflow (http://stackoverflow.com/questions/11992139/jquery-ajax-to-asp-net-asmx-web-service-throws-request-format-is-invalid-applic)

在IIS服务器上.NET4.0环境下,用Ajax请求asmx的web服务,出现以下错误:

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

Ajax代码:

$.ajax({ type: "POST", url: "/WebService1.asmx/Test", data: JSON.stringify({"code": 1234}), contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg); } });

在web.config中修改配置,解决方案:

<system.webServer> <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>

网址:错误手札 https://www.yuejiaxmz.com/news/view/484904

相关内容

札幌市有哪些生活垃圾再生利用设施和机构?
dart 错误
札幌购物攻略!购物商场、百货公司、商店街等必逛景点大公开
日本札幌大学交流感悟(2024年10月)——外国语学院日语专业郭雨婷
运行时错误
老照片第一三八辑阅读札记.docx
《全民数字素养提升100问》札记
错误生活决策题
IIS 7.5 详细错误
站点错误

随便看看