Thoughts on the reusability of httphandler

Source: Internet
Author: User
I have never understood the reusability of ihttphandler. Today I read an article ArticleIn general, each request is initiated by an httphandlerfactory to initialize an ihttphandler instance. Whether the handler is in a State is not determined by whether the class has a member variable. It depends on whether it depends on httpcontext. request, because the context is used as the parameter when it is initialized by the factory. It should be understood in this way. When isreusable is true, CLR will maintain an object pool. This is usually done only when the handler is created with a large overhead, and it should also be stateless.

But there is still a problem, that is, what if ihttphandler enables it to support output caching like aspx? Further research may be required.

The handler can be reused in such a case. This is obvious as long as it does not depend on context. Request. Of course, there cannot be member variables.

In addition, it is better not to use the. ashx file, but to directly set the corresponding handler class in Web. config, because these are more flexible for changing handler and direct prizes.CodeIf it is written in. ashx, it will be compiled only when it is requested, slightly affecting the speed. In addition, it takes into account the code security issues.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.