-2

This works perfectly for what I am doing except one thing -- I'd like it to return a thumbnail image instead of a string. Is this possible in mvc3. This is my controller and I'm using an Ajax.ImageActionLink. I am a novice and am muddling through things. Thanks.

    public string ThankYou()
    {
        System.Threading.Thread.Sleep(15000);
        return "Serenity Equine Rescue";
    }
4

2 回答 2

1

如果您的方法是动作,您只需使用您所在的FileResult控制器类上的方法之一。

顺便说一句,动作方法不应该返回任何东西,而是ActionResult它的后代。

于 2012-08-08T18:11:04.403 回答
1
public ActionResult ThankYou()
{
    byte[] imageData = ...
    return File(imageData, "image/png");
}

或者如果它不是动态图像:

public ActionResult ThankYou()
{
    string imageFile = @"c:\images\foobar.png";
    return File(imageFile, "image/png");
}

然后您可以使用<img>标签来显示此图像:

<img src="@Url.Action("ThankYou")" alt="some image" />
于 2012-08-08T18:12:04.110 回答