問題:
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?