C# .net MVC显示来自db的多张照片时会显示重复的照片

C# .net MVC显示来自db的多张照片时会显示重复的照片,c#,asp.net-mvc,photo,C#,Asp.net Mvc,Photo,我使用了我在几个论坛上看到的示例,在视图上显示字节[]。我遇到的问题是,有时视图上会复制照片。例如,我想显示photo1和photo2。当页面加载时,我看到photo1和photo2。我刷新页面,可能会看到photo1两次或photo2两次 更新: 我发现了我的问题。我在我们的后端代码中发现了一个不是为线程安全而编写的类。它正在保存有关请求的照片的状态。因此,根据照片请求的时间,两个请求可能返回相同的照片 这是我的控制器代码 public virtual ActionResult Get

我使用了我在几个论坛上看到的示例,在视图上显示字节[]。我遇到的问题是,有时视图上会复制照片。例如,我想显示photo1和photo2。当页面加载时,我看到photo1和photo2。我刷新页面,可能会看到photo1两次或photo2两次

更新:

我发现了我的问题。我在我们的后端代码中发现了一个不是为线程安全而编写的类。它正在保存有关请求的照片的状态。因此,根据照片请求的时间,两个请求可能返回相同的照片

这是我的控制器代码

    public virtual ActionResult GetImage(int id) {

        ClientDataPortal portal = new ClientDataPortal();
        GetPhotosCommand command = new GetPhotosCommand();
        command.GetPhotosActionEnum = GetPhotosActionEnum.GETDISTRIBUTORPHOTO;
        command.PhotoSearchCriteria = new PhotoSearchCriteria();
        command.PhotoSearchCriteria.DistributorPhotoId = id;
        DistributorPhotoData item = portal.Fetch<DistributorPhotoData>(command);
        //return new FileStreamResult(new System.IO.MemoryStream(item.Thumbnail), "image/jpeg");
        return File(item.Thumbnail, "image/jpeg");

    }
下面是视图中的代码

            <table>
                @foreach (var item in Model.DistributorPhotos) {     
                    <tr>  
                        <td  id="item.DistributorPhotoId.ToString()" >              
                        <img id="item.DistributorPhotoId.ToString()" src="@Url.Action("GetImage", "Photo", new { id = item.DistributorPhotoId })" alt="Image" />
                        </td>
                        <td>@item.DistributorPhotoId.ToString()</td>
                   </tr>
                }
            </table>

生成的HTML是什么?也许Model.DistributorPhotos中的ID有重复项?