从View调用标识异步方法

时间:2016-12-11 23:44:07

标签: asp.net-mvc asp.net-identity

我已经向标准身份用户添加了一堆属性(感兴趣的主要属性是ImageData和ImageMimeType)。现在我需要在我的视图中显示用户的图片。我的ImageController有以下方法:

public async System.Threading.Tasks.Task<FileContentResult> GetImageByUser(string id)
{
    var user = await UserManager.FindByIdAsync(id);
    return File(user.ImageData, user.ImageMimeType);
}

在我看来,我只需要按如下方式显示返回的文件:

<img id="ContestantPicture" class="img-thumbnail" width="50" height="50" scr="@Url.Action("GetImageByUser", "Image", new { id = Model.UserParticipation.UserId })" />

毋庸置疑,图像不会显示在视图上。我对C#中的任务不太熟悉,所以我不太清楚如何解决这个问题。

0 个答案:

没有答案
相关问题