Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OWIN IIS主机死锁_C#_Asp.net Mvc_Iis_Asp.net Web Api_.net 4.5 - Fatal编程技术网

C# OWIN IIS主机死锁

C# OWIN IIS主机死锁,c#,asp.net-mvc,iis,asp.net-web-api,.net-4.5,C#,Asp.net Mvc,Iis,Asp.net Web Api,.net 4.5,我选择在某个具体项目中使用OWIN IIS主机,当我想从Web API资源发送请求时,我陷入了死锁 以下是启动类代码: [assembly: Microsoft.Owin.OwinStartup(typeof(MyProduct.IdentityClient.Startup))] namespace MyProduct.IdentityClient { using Newtonsoft.Json.Serialization; using Owin; using Serv

我选择在某个具体项目中使用OWIN IIS主机,当我想从Web API资源发送请求时,我陷入了死锁

以下是
启动
类代码:

[assembly: Microsoft.Owin.OwinStartup(typeof(MyProduct.IdentityClient.Startup))]

namespace MyProduct.IdentityClient
{
    using Newtonsoft.Json.Serialization;
    using Owin;
    using ServerMyWeb.Shared.Http;
    using System.Web.Http;

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();

            app.UseWebApi(config);
        }
    }
}
我已经实现了某种代理,它向其他API(即另一个主机)执行实际的HTTP请求。当我执行该请求时,代理Web API进入死锁状态

    // Simplified sample of proxying a HTTP/GET request
    public virtual Task<HttpResponseMessage> Get(string apiRelativeUri)
    {            
        HttpRequestMessage request = ControllerContext.Request;

        request.RequestUri = new Uri("[URI to some API]");

        // Client == HttpClient singleton
        // HERE IS THE DEADLOCK. Client.SendAsync never returns/continues
        HttpResponseMessage response = await Client.SendAsync(request);

        // Some stuff to maniuplate response message... 

        return response;
    }
//代理HTTP/GET请求的简化示例
公共虚拟任务Get(字符串API)
{            
HttpRequestMessage请求=ControllerContext.request;
request.RequestUri=新Uri(“[Uri到某个API]”);
//Client==HttpClient singleton
//这是死锁。Client.SendAsync永远不会返回/继续
HttpResponseMessage response=等待客户端.SendAsync(请求);
//一些东西可以上传回复信息。。。
返回响应;
}
我做过类似的实现,它在OWIN/Katana中工作,我确信这与IIS进程和线程模型有关,它有副作用(可能在HttpClient.SendAsync结束异步操作后无法恢复请求线程以继续…)

您是否有关于OWIN IIS托管问题的任何消息以及可能的解决方案(或者我在IIS上托管OWIN时跳过了一些配置步骤…?

注意:在我的代码执行期间,没有
任务.Result
任务.Wait
任务.WaitAll
,或类似的内容

更新:
我可以确认这是OWIN IIS托管的一个问题,因为我对ASP.NET Web API初始化进行了最低限度的重构,以使用老式的
Global.asax
GlobalConfiguration
,并且相同的代码工作正常。

您是否已经尝试过HttpResponseMessage response=wait Client.sendaync(request).configurewait(错);?@FlorianMoser很遗憾,是的,我尝试了这个,但没有运气……可能是网络跟踪会给出一些提示。下面是如何启用网络跟踪的链接。@PankajKapare我认为这是一个线程问题,因为当我将
SendAsync
任务
设置为变量时,我会
线程。睡眠(…)
在很长一段时间内,我观察任务状态,它总是
等待激活
我对OWIN的异步/等待代码有类似的问题。在VS 2013上。您有一些新信息吗?