0
votes

Can I create a Controller that simply returns an image?

I would like to route this logic through a controller, whenever a variable [LOGO] such requested,

The controller will look up logo.png and replace the image to the variable [LOGO].

I don't want to use a View. I want to do it all with just the Controller.

Is this possible?

I tried some way by following code,

EmailHelper.SendEmail(
    Constants.EmailSender.CandidateSupport,
    candidate.Email,
    Constants.EmailSubject.CandidateUpdateProfile,
    Constants.EmailBody.CandidateUpdateProfile
    .Replace("[LOGO]", Url.Content("~/Content/Images/logo_small2.png"))
1

1 Answers

0
votes

I am not entirely sure what you need, but in answer to "Can I create a Controller that simply returns an image?" you can do this as follows:

public FileResult Image(string filePath)
{
    //get your stream
    return File(stream, "image/png");
}

Obviously you'd need to think about security given that you are returning items from the file system.