0

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

1 Answer 1

1

Try using "GET" not "Get"

It's case sensitive apparently.

[WebInvoke(Method = "GET" ...
Sign up to request clarification or add additional context in comments.

1 Comment

Yes. you are right. i tried that but i am getting another error. "Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.