I have complete image location stored in Database.The image is stored in that particular location. I want to display the image in the view. How to do this?
I have complete image location stored in Database .The image is stored in that
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since the path is not within the site you need to do this in the controller:
So what we have is a controller that will get the image path from the database, and return the file. Now this will return the file, but if you want to display it in the view, you would do this:
So what happens now is when the view is loading, it calls the Image action from
ImageControllerand passes itidOfImageInDB(the database key of the image you want) and displays the image.Note that you need to have
ImageControllerbe the name of the conctroller theImage ActionResultis in, andidOfImageInDBis theintthat is used to find the image.