ASP.NET MVC 控制器可以返回图像吗? - Can an ASP.NET MVC controller return an Image?

问题:

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?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章