1

我正在尝试从客户端接收来自 WCF 方法的答案。当我尝试执行 void 方法时,它们工作正常。例如:

Uri u = new Uri(string.Format(LogIn.ctx.BaseUri + "/CreateRole?name='{0}'",
TextBox1.Text), UriKind.RelativeOrAbsolute);

LogIn.ctx.Execute(u, "GET");

现在我想调用一个返回布尔值的方法,并且将使用这个值。这是我要调用并接收其返回值的方法:

[WebGet]
public bool Controler(string role, string user)
{
    if (Roles.IsUserInRole(user, role))
    {
        return true;
    }
    else
    {
        return false;
    }
}
4

1 回答 1

0

而不是LogIn.ctx.Execute(u, "GET"),试试这个:

IEnumerable<bool> result = LogIn.ctx.Execute<bool>(u);
bool answer = result.Single();
于 2013-05-08T18:04:29.883 回答