Reputation: 3945
<img src='@Url.Action("Index", "ReturnImage", new { guid = @Model.GUID })' alt="Doorstep signature" style="width:290px;height:290px;" />
With the above line of code I am trying to access ReturnImageController and pass @Model.GUID to the Index function....where it should return an image:
[Authorize]
public ActionResult Index(string guid)
{
OrderSignatureRecord order = _signatureService.GetByGUID(guid);
string pathToImage = order.PathToImageFile;
var dir = Server.MapPath("/" + order.PathToImageFile);
var path = Path.Combine(dir, guid + ".jpg");
return base.File(path, "image/jpeg");
}
ive used debug to see what HTML is returned:
<img src='/OrchardLocal/RainBowProject/ReturnImage' alt="Doorstep signature" style="width:290px;height:290px;" />
So something is returned but it doesnt use GUID to search for the proper one.
Any ideas as to what is going wrong? thanks
Upvotes: 0
Views: 136
Reputation: 919
Try to return the var path not the base.File (I think you want to return the actual file content with mime-type), but you need the file name.
Upvotes: 0
Reputation: 156948
You can do this in two ways:
Return the file location, not the content (msdn says on your base.File: Creates a FileContentResult object);
Return the content and use this code (only recommended for small images)
<img src="data:image/png;base64,@Url.Action("Index", "ReturnImage", new { guid = @Model.GUID })" />
Upvotes: 1