1

私がやろうとしているのは、ロールがユーザーに影響を与えるかどうかをテストすることです.WCF Data Serviceでテストが公開されているメソッド(図1)で、クライアント側。返される簡単なテストをテストし、送信したいものを取得したため、呼び出しは正しいですが、メソッドの本体を変更して、ユーザーがロールにいるかどうかに関係なく送信すると、例外が発生します( dataservicequeryexception )

図 1:

    [WebGet]
    public bool Controler(string role, string user)
    {

       if(Roles.IsUserInRole(user,role))
        { return true; }

            return false; 
    }

図 2:

      Uri u = new Uri(string.Format(LogIn.ctx.BaseUri + "/Controler?role='{0}'&user='{1}'",
        "Serveur","Oussama"), UriKind.RelativeOrAbsolute);

        IEnumerable<bool> result = LogIn.ctx.Execute<bool>(u);
        bool res = result.Single();

        if (res == true)
        {
            Response.Redirect("Index.aspx");
        }

        else
        {
            Response.Redirect("Error.aspx");
        }

みんな、ありがとう !

4

0 に答える 0