问题描述
我已经阅读到HttpHandlers不是ASP.NET 5(vNext)的一部分,是否可以使用替代品tha来实现相同的功能.
I have read that HttpHandlers is not part of ASP.NET 5 (vNext)Is there a replacement tha can be used instead that works the same.
我正在寻找一种可以根据实体的ID加载图像的解决方案.如果该图像不存在,则应显示[非图像]图像.这与http处理程序完美配合.但是我在ASP.NET vNext中看不到一个好的解决方案.
I am looking for a solution that can load an image based on id from a entity. And if that image doesn't exist, a [Non Image] Image should be shown instead. This works perfect with http handler. But I don't see a good solution in ASP.NET vNext.
推荐答案
替换 HttpHandler
和 HttpModule
是中间件.您可以轻松编写一个中间件来处理您的问题.
但是,在您的特定情况下,自定义 Image TagHelper
可能会更有用.
TagHelper示例
中间件示例
The replacement of HttpHandler
and HttpModule
is middleware. You can easily wrote a middleware to handle your issue.
However in your particular case a custom Image TagHelper
can be more usefull.
TagHelper sample
Middleware sample
这篇关于在ASP.NET vNext中替换HttpHandlers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!