C# 访问wcf rest函数时出错

C# 访问wcf rest函数时出错,c#,asp.net,wcf,web-services,C#,Asp.net,Wcf,Web Services,当我尝试访问wcf rest时,出现以下错误 合约“SelectorFront”中的操作“Login”指定WebGetAttribute/WebInvokeAttribute上的方法“Get”,但该方法唯一允许的值是Get或POST。“System.ServiceModel.Description.WebScriptEnableBehavior”不支持其他值。 我创建了一个wcf rest,有1个方法“Login”,还有一个参数“Username” 这是我的函数调用 localhost:2664

当我尝试访问wcf rest时,出现以下错误

合约“SelectorFront”中的操作“Login”指定WebGetAttribute/WebInvokeAttribute上的方法“Get”,但该方法唯一允许的值是Get或POST。“System.ServiceModel.Description.WebScriptEnableBehavior”不支持其他值。

我创建了一个wcf rest,有1个方法“Login”,还有一个参数“Username” 这是我的函数调用

localhost:2664/FrontService.svc/Login?Username=max

我的wcf如下

接口

[OperationContract]
[WebInvoke(Method = "Get", UriTemplate = "/Login/{UserName}", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
string Login(string UserName);
public string Login(string UserName)
{
tblUser obj = (from m in dataContext.tblUsers
where m.UserName == UserName
select m).First();
JavaScriptSerializer oSerializer = new JavaScriptSerializer();
string sJSON = oSerializer.Serialize(obj);
return sJSON;
}
服务

[OperationContract]
[WebInvoke(Method = "Get", UriTemplate = "/Login/{UserName}", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] 
string Login(string UserName);
public string Login(string UserName)
{
tblUser obj = (from m in dataContext.tblUsers
where m.UserName == UserName
select m).First();
JavaScriptSerializer oSerializer = new JavaScriptSerializer();
string sJSON = oSerializer.Serialize(obj);
return sJSON;
}
此问题的解决方案是什么

尝试使用“获取”而不是“获取”

显然是区分大小写的

[WebInvoke(Method = "GET" ...

对你是对的。我试过了,但又犯了一个错误。“使用'UriTemplate'的终结点不能与'System.ServiceModel.Description.WebScriptEnableingBehavior'一起使用”