TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sisovin CHIENG
NA
3
3.3k
Inputstream and contentlength is missing in microsoft.aspnet
Apr 1 2016 10:10 AM
As my review to the Microsoft.AspNet.Http.Abstractions, the IFormFile is missing the InputStream and ContentLength in ASP.NET MVC 6, it insteads of OpenReadStream, which is not functioned to respnse to the ConvertToBytes, for example:
private
byte
[] ConvertToBytes(IFormFile image)
{
byte
[] imageBytes =
null
;
//Then, Read stream in Binary
BinaryReader reader =
new
BinaryReader(image.InputStream);
imageBytes = reader.ReadBytes((
int
) image.ContentLength);
return
imageBytes;
}
Do you know what happen to InputStream and ContentLength? In the IFormFile, are available of OpenReadStream and Length. I don't know how to use it. Do anyone know how to use it. I would like to have similar code as below example:
private
byte
[] ConvertToBytes(IFormFile image)
{
byte
[] imageBytes =
null
;
//Then, Read stream in Binary
BinaryReader reader =
new
BinaryReader(image.OpenReadStream());
imageBytes = reader.ReadBytes((
int
) image.Length);
return
imageBytes;
}
What I have tried below code, but it does't work because of BinaryReader reader = new BinaryReader(image.OpenReadStream()) show up System.NullReferenceException was unhandled by user code with HResult=-2147467261
and the Message=Object reference not set to an instance of an object.:
private
byte
[] ConvertToBytes(IFormFile image)
{
byte
[] imageBytes =
null
;
//Then, Read stream in Binary
BinaryReader reader =
new
BinaryReader(image.OpenReadStream());
imageBytes = reader.ReadBytes((
int
) image.Length);
return
imageBytes;
}
Can you help me to resolve this problem?
Attachment:
publisherinfosrepository.rar
Reply
Answers (
1
)
nested webgrid data call in controller in MVC 4
j -query is not working correctly?