Reputation: 2630
I am getting following error when i try to access the wcf-rest.
Operation 'Login' in contract 'SelectorFront' specifies Method 'Get' on the WebGetAttribute/WebInvokeAttribute, but the only allowed values for Method are GET or POST. Other values are not supported by 'System.ServiceModel.Description.WebScriptEnablingBehavior'.
I have created a wcf-rest, with 1 method "Login" and has one parameter "Username" This is my function call.
localhost:2664/FrontService.svc/Login?Username=max
And my wcf is as following
Interface
[OperationContract]
[WebInvoke(Method = "Get", UriTemplate = "/Login/{UserName}", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string Login(string UserName);
Service
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;
}
what is the solution of this issue
Upvotes: 0
Views: 616
Reputation: 7105
Try using "GET" not "Get"
It's case sensitive apparently.
[WebInvoke(Method = "GET" ...
Upvotes: 1