The value 'Capturetest1.png' is not valid for Imagedata.
I'm not sure I understand what you mean by this. In your HTML you have identified the input as type file. That means the user will get browse button and the ability to select a file. The underlying value is going to be a string.
In you model you are passing byte arrays for the 2 images. That is the actual file contents. You cannot bind the file contents to an input field marked as type file. If you want to display the filename in the HTML then in the model change the properties to strings. Then assign the filename to be shown to the properties, don't load the file itself.
If you want to show the images in the HTML then you'll need to add an img
element instead. Set the URL of the image to be the URL to the image file. If you're storing the image file on disk then use the relative path to that file otherwise you'll have to create a server endpoint to expose the image. It is that code that will be responsible for sending the byte array to the browser.
You can see a full example of how to do this in the ASP.NET Docs. Refer to their example code on how to properly set up your HTML and model backend.
Finally note that your code appears incorrect to me. If imagedata != null
then you do work to load the image and store it in question.Imagedata
. You then do the same thing for imagesol
. However you have a copy/paste error in that it is assigning the results to question.Imagedata
instead of question.Imagesol
.