I'm looking to do something like this:-
View1 contains a form with a file upload control, for the user to upload an image. This gets POSTed to the controller, where the image is resized and converted to greyscale (the new image is unlikely to be more than 5kb in size).
I then want to redirect to View2 where I display this new image, along with a "save" button. Clicking this will result in the image being saved to a DB.
What I'm not sure about is how best to pass the image around. I wondered about doing something like this:-
- After the image has been manipulated in the View1 POST method, the image data is stored in a model and passed to View2 using
RedirectToAction()
- The View2 GET method simply passes this model to the view, so it can be displayed. The image data is also stored in a hidden field in the view.
- When the user clicks "save" this is POSTed back, where the controller saves it to the DB.
I'm new to MVC, so am wondering if this an acceptable solution? It doesn't feel quite right "round-tripping" the image data in this way, and wondered if there is a more suitable approach or mechanism (e.g. TempData or session state)?