【发布时间】:2011-08-08 14:38:29
【问题描述】:
希望您能提供帮助,我正在尝试升级损坏的登录系统,以便在传输登录凭据时使用 POST 而不是 GET。
它永远不会到达实际的方法,所以问题出在界面和我的 javascript 之间。
界面:
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
UriTemplate = "/DoLogin")]
LoginKey DoLogin(string email, string password,string tenant);
Javascript:
$.ajax({
type: "POST",
url: "RestService.svc/DoLogin",
data:'{"email":"' + encodeURIComponent(email) + '","password":"' + encodeURIComponent(password) + '","tenant":"' + encodeURIComponent(tenant) + '"}',
dataType: "json",
cache: false,
success: function (loginKey) {
... rest of method
我发送的 JSON 数据是有效的: { “电子邮件”:“邮件”, "密码": "某个密码", “租户”:“租户” } 任何想法这里出了什么问题?它与 GET 一起工作得很好
ps这里是实际登录rest服务方法的第一行:
public LoginKey DoLogin(string email, string password, string tenant)
{
【问题讨论】:
-
你能发布你遇到的错误吗?
-
另外,请发布您的 WCF 服务配置。
标签: javascript .net wcf json rest