Convert HttpRequestMessage to HttpRequest

前端 未结 2 1986
借酒劲吻你
借酒劲吻你 2021-02-12 17:57

I\'m converting ASP.NET web application to MVC Web Api project. One of my methods expects HttpRequest class. However, Web Api controller holds only HttpReques

2条回答
  •  隐瞒了意图╮
    2021-02-12 18:26

    You probably don't need to convert from HttpRequestMessage. There is another way:

    var context = new HttpContextWrapper(HttpContext.Current);
    HttpRequestBase request = context.Request;
    

提交回复
热议问题