asp.net中的ASHX处理程序文件有什么好处? [英] What are the benefits of an ASHX handler file in asp.net?

查看:94
本文介绍了asp.net中的ASHX处理程序文件有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ashx或处理程序有什么好处?另外,如果我使用MVC,我是否需要它们(为什么不这样做)?

What are the benefits of using an ashx, or handler? Also, do I need them if I use MVC (and why not)?

框架(2.0+)有关系吗?

Does the framework matter (2.0+)?

我为什么要使用处理程序?最近建议我使用一个来检索图像,但我不知道为什么.

Why would I want to use a handler? I was recently recommended to use one for retrieving an image but I don't know why.

谢谢您的时间.

编辑-处理程序更快吗?

Edit - is a handler faster?

推荐答案

仅举几个例子:

  1. 动态图像生成:您可以编写返回数据驱动的图像的处理程序,方法是创建一个返回图像数据的ASHX处理程序,然后在标记中使用该URL.例如<img alt="user's custom icon" src="Icon.ashx?username=bob"></img>

  1. Dynamic image generation: You can write handlers that return data driven images by creating an ASHX handler that returns image data and then using that URL in your tags. e.g. <img alt="user's custom icon" src="Icon.ashx?username=bob"></img>

将基于REST的XML或JSON数据返回到客户端上的AJAX代码.

Returning REST-based XML or JSON data to AJAX code on the client.

我相信从1.0开始就可以使用

I believe this has been available since 1.0

这篇关于asp.net中的ASHX处理程序文件有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆