WCF异常在Google Chrome浏览器中返回空的Jquery错误
我有一个发送密码的wcf . 我尝试过强制错误,但$浏览器返回为空 . jquery ajax错误 .
wcfUser.svc:
[OperationContract(),WebInvoke(Method =“POST”,RequestFormat = WebMessageFormat.Json,ResponseFormat WebMessageFormat.Json =)] public string lembrarSenha()
{
尝试
{
int id = Convert.ToInt32(“asssaas”);
return id.ToString();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.ContentType =“application / json”;
HttpContext.Current.Response.Flush();
返回ex.Message;
}
}
jQuery的:
$ . ajax({url:“wcf / wcfUser.svc / lembrarSenha”,
类型:“POST”,
contentType:“application / json; charset = utf-8”,
dataType:'json',
ProcessData:true,
成功:函数(msg){
if(msg.d == true){
提醒(“请检查您的收件箱中的电子邮件 . ”);
其他{}
alert(“电子邮件未在系统中注册 . ”);
}
}
错误:函数(XHR,ErrorText,thrownError){
alert(xhr.responseText);
}
});
必须返回错误,但在Chrome中返回空,在其他浏览器中正确返回错误 .