简体   繁体   中英

ASP.NET Core HttpRequest class has no BinaryRead method

I am working on an ASP.NET Core app, however they don't seem to have ported the entire HttpRequest class into Microsoft.AspNetCore.Mvc. This method is missing:

https://msdn.microsoft.com/en-us/library/system.web.httprequest.binaryread(v=vs.90).aspx

Is there another way to do the same thing? I don't see a similar method to replace it.

You can use a MemoryStream on the Request and retrieve the content of the Body .

Something like:

using (var ms = new MemoryStream(2048))
{
    await Request.Body.CopyToAsync(ms);
    var rawData = ms.ToArray();  
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM