小编Art*_*CLI的帖子

从ASP.NET MVC中的控制器调用异步任务<>

我有一个库包装器OVH API,我尝试调用一个函数来获取ASP.NET MVC项目中的我的使用者密钥.它适用于Console项目应用程序,但该方法永远不会在我的Controller中响应:库中的方法

public async Task<CredentialsResponse> RequestCredential(IEnumerable<AccessRule> accessRules, string redirectUrl = null)
    {
        Ensure.NotNull("accessRules", accessRules);

        CredentialsRequest cmd = new CredentialsRequest();
        cmd.AccessRules.AddRange(accessRules);
        cmd.Redirection = redirectUrl;

        if (cmd.AccessRules.Count == 0)
            throw new ArgumentException("You must specify at least one accessRule");
        return await RawCall<CredentialsResponse>(HttpMethod.Post, "/auth/credential", cmd;
    }
Run Code Online (Sandbox Code Playgroud)

我打电话给控制器:

public ActionResult Index()
    {
        Information infosClient = new Information();

        OvhApiClient api = new OvhApiClient("", "", OvhInfra.Europe);

        CredentialsResponse response = api.RequestCredential(new[]{
            new AccessRule{ Method = "GET", Path = "/*"},
            new AccessRule{ Method = "PUT", Path = "/*"}, …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asynchronous

1
推荐指数
1
解决办法
4170
查看次数

标签 统计

asp.net-mvc ×1

asynchronous ×1