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 HttpRequestMessage
(this.Request
) object.
Do you know how I can convert HttpRequestMessage
to HttpRequest
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You probably don't need to convert from HttpRequestMessage. There is another way:
var context = new HttpContextWrapper(HttpContext.Current);
HttpRequestBase request = context.Request;
回答2:
Try to use/create a HttpRequestWrapper using your HttpRequestBase.