Asp。Net MVC控制器动作返回动画gif问题

时间:2021-07-14 04:13:37

I have a situation where I want to return an animated gif from an ASP.Net MVC controller action. I then want to construct an anchor tag like this:

我有一个情况,我想返回一个动画gif从ASP。净MVC控制器动作。然后我想构建一个锚标签,如下所示:

<img src="/MyController/MyAction" id="company-logo" alt="Company Logo" />

The idea is that I want to be able to allow users to upload their own company logo and the controller action should retrieve their specific logo from the server.

我的想法是允许用户上传他们自己的公司标志,控制器动作应该从服务器检索他们的特定标志。

However since my src attribute value does not end with .gif, the browser does not seem to be recognizing it as a gif and therefore does not animate it.

然而,由于我的src属性值并没有以.gif结束,浏览器似乎没有识别它为gif,因此没有动画。

I know the controller action is returning it as a gif because when i load it from file I give it the file format as gif.

我知道控制器动作将它作为gif返回因为当我从文件中加载它时,我将它的文件格式设为gif。

Does anyone have any suggestions as to how to go about getting my desired functionality?

对于如何实现我想要的功能,有人有什么建议吗?

1 个解决方案

#1


2  

The file extension would have nothing to do with it at all. Perhaps you need to make sure that your controller is setting the correct MIME type to image/gif? The browser can 'guess' at the content type sometimes, but it may not animate a gif in such a circumstance.

文件扩展名与它没有任何关系。也许您需要确保您的控制器将正确的MIME类型设置为image/gif?浏览器有时可以“猜测”内容类型,但在这种情况下,它可能不会激活gif。

#1


2  

The file extension would have nothing to do with it at all. Perhaps you need to make sure that your controller is setting the correct MIME type to image/gif? The browser can 'guess' at the content type sometimes, but it may not animate a gif in such a circumstance.

文件扩展名与它没有任何关系。也许您需要确保您的控制器将正确的MIME类型设置为image/gif?浏览器有时可以“猜测”内容类型,但在这种情况下,它可能不会激活gif。