积极答复者
用ScriptManager调用WCF中方法,我想用AJAX实现,但是,当参数长度大于128K就会调用失败。详细请进

问题
-
如题,
具体是这样的,我用WCF提供内容提交的方法,通过ScriptManager调用。想AJAX提交,但是当文章的内容大于128K左右就会调用失败,这个不是.NET抛出的异常,貌似是JS直接调用失败,失败的信息就是 某”****“方法 调用失败,没有堆栈和错误类型信息。
我想问的是,JS对参数的值的长度有限制?或则 ScriptManager调用的WCF有限制?提交文章我没有用POST,只是单纯的调用WCF的方法。
测试环境:
.net 4.0 opera 11.11和ie8 VS2010开发IIS 值是从CKeditor 获取的
附上代码:
WCF的方法
/// <summary> /// 添加条目 /// </summary> /// <param name="title">标题</param> /// <param name="topic">分类ID</param> /// <param name="isenablecomment">是否允许评论</param> /// <param name="createtime">创建事件</param> /// <param name="content">内容</param> /// <param name="moduleid">栏目ID</param> /// <returns></returns> [OperationContract] [WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest)] public bool CreateItemClick(string title, string categoryid, string isenablecomment, string createtime, string content, string moduleid, string stateid) { try { PowerChecker pc = new PowerChecker(true, UserPower.栏目管理员, moduleService.Find(long.Parse(moduleid))); if (!pc.Check()) throw new Exception("没有登录或权限不够!"); content = HttpContext.Current.Server.HtmlEncode(content); articleService.Insert(title, createtime, 3, categoryid, content, stateid, moduleid, isenablecomment); articleService.Save(); } catch (Exception e) { throw e; } return true; }
ScriptManager 代码
<asp:ScriptManager runat="server" ID="ssmanager"> <Services> <asp:ServiceReference Path="~/WCF/Wcf.svc" /> </Services> </asp:ScriptManager>
js代码,用的jquery
$("#btnHand").click(function () { if (!CheckData()) return; var title = $("#tbTitle").val(); var topic = $("#ddlTopic").val(); var isComment = $("[name='select']")[0].checked ? "true" : "false"; var createTime = $("#tbCalendar").val(); var content =tbMemo.getData(); var stateid = $("#ddlState").val(); Wcf.CreateItemClick(title, topic, isComment, createTime, content, moduleid, stateid, GetMessage, ErrorHandle); }); var ErrorHandle = function ErrorHandle(result) { // var msg = "错误类型:" + result.get_exceptionType() + "\r\n"; var msg = ""; msg += "错误信息:" + result.get_message() + "\r\n"; sAlert(msg, true, 3);<br/> $("#lblInfo").html("提交失败!"); } var GetMessage = function (result) { var moduleid=$("#moduleid").val(); $("#AjaxLoader").css("z-index", "-100"); if (result) { $("#lblInfo").html("添加成功!"); sAlert("添加成功!2秒后跳转到条目列表……<a href='ArticleList.aspx?moduleid="+moduleid+"'>如果您的浏览器没有跳转请点击这里.......</a>", false, 3); setTimeout("location='ArticleList.aspx?moduleid="+moduleid+"';", 2000);<br/> } else {<br/> $("#lblInfo").html("添加失败!"); sAlert("添加失败!", false, 3); } }
当触发JS函数时,直接写的:调用“ CreateItemClick”函数失败。小弟在此谢谢了。