简体   繁体   中英

Generic HttpHandler vs normal aspx Page HttpHandler

Is there any difference in using Generic HttpHandler(ashx) instead of normal aspx Page for returning daynamic Images as stream. Every tutorial that I have read about serving dynamic files uses generic handler but I can't seem to find any comparasion article between those two. Can someone explain why it is good to use Generic handler instead of Page Handler for this task?

Thanks.

An ASPX page is already a generic handler as it implements IHttpHandler interface. It's just that it contains lots of code that's absolutely unnecessary when all you need is to generate a dynamic image. So implementing a custom handler will be faster in terms of performance.

Just look at a typical WebForm page lifecycle (ASPX):

在此处输入图片说明

All this is useless when all you need is to generate a dynamic image. All you care about is the ProcessRequest method and write directly to the response stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM