问题:
Can I create a Controller that simply returns an image asset?我可以创建一个只返回图像资产的控制器吗?
I would like to route this logic through a controller, whenever a URL such as the following is requested:每当请求如下 URL 时,我想通过控制器路由此逻辑:
www.mywebsite.com/resource/image/topbanner
The controller will look up topbanner.png
and send that image directly back to the client.控制器将查找topbanner.png
并将该图像直接发送回客户端。
I've seen examples of this where you have to create a View - I don't want to use a View.我见过这样的例子,你必须创建一个视图 - 我不想使用视图。 I want to do it all with just the Controller.我只想用控制器来完成这一切。
Is this possible?这可能吗?
解决方案:
参考一: https://stackoom.com/question/mP0参考二: Can an ASP.NET MVC controller return an Image?