dimanche 4 octobre 2020

How to upload an image to a model in Razor pages?

I want to make an e-commerce like web app using ASP.NET Core.

Creating the models is ok, but I need to make a way to upload images for the products.

Razor pages allow only one @model, and this way I can't access the Image class that I created for uploading the images. This Image class is just a class for uploading, that will contain the path of the image, the id, the description and a NotMapped IFormFile property to do the upload.

But for UX purposes, the user(the owner of the e-commerce) to fill the Product model and uploading the image in the same page, and do the POST in the same form. But with the Razor pages allowing just one model, how can I do that? This way is dumb, impossible or both?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire