当我试图访问wcf-rest时,我会得到以下错误。
操作“SelectorFront”在WebGetAttribute/WebInvokeAttribute上指定了方法' GET‘,但是惟一允许的方法值是GET或POST。'System.ServiceModel.Description.WebScriptEnablingBehavior'.不支持其他值
我已经创建了一个wcf-rest,它有一个方法"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;
}这个问题的解决办法是什么?
发布于 2012-12-19 13:38:45
尝试使用“获取”而不是“获取”
显然是对大小写敏感的。
[WebInvoke(Method = "GET" ...https://stackoverflow.com/questions/13953603
复制相似问题