在asp.net MVC4中显示图像时图像变为白色

时间:2019-03-25 07:45:57

标签: asp.net-mvc asp.net-web-api blob

我正在设置一个简单的应用程序,该应用程序将调用WebApi,然后将其显示在我的应用程序中。

webapi返回的blob类型字符串如下所示。-enter image description here

然后我使用此方法接收并显示它:

模型 enter image description here

控制器

查看 enter image description here

然后,当我运行应用程序时,图像变成白色: enter image description here

我该如何解决?

编辑1

现在图像可以很好地显示,但是当我调整窗口大小时,图像再次变白。enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

删除此行,因为您的API返回base64字符串格式。

@Effect()
loadConfig$: Observable<Action> = this.actions$
    .ofType<servicesActions.LoadConfig>(servicesActions.LOAD_CONFIG)
    .switchMap(action => Observable.of(
        new OtherAction(),
        new OtherAction2(),
    );

并且仅使用此行

var base64 = Convert.ToBase64String(logo.imagenes);

更新:

如果图像显示以及您调整大小时均未显示,请检查CSS,调整大小时您还记得var imgSrc = String.Format("data:image/jpeg;base64,{0}",logo.imagenes); 吗?

我在API的基础上制作了一个演示显示图像,它不会因调整大小而受影响。

base64
.circle{
			    border-radius: 50%;
				width: 200px;
				height: 200px;
			}

相关问题