问题
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.
来源:https://stackoverflow.com/questions/16272452/convert-httprequestmessage-to-httprequest