IIS7 will reuse HttpHandler that should not be reused

Source: Internet
Author: User
Tags iis
Iis

First, to implement a IsReusable property when implementing IHttpHandler, this property tells ASP.net whether this httphandler is reusable. If a HttpHandler is reusable, then multiple requests are likely to use the same HttpHandler instance, and if a httphandler is not reusable, Then asp.net should make sure that each request is using a newly constructed HttpHandler instance.

Page is designed to be not reusable, so each request causes a new page instance to be constructed, because the page's lifecycle cannot be restored to its original state, and a page cannot be used to process the next request after it has passed its lifecycle. Similarly, if we have a httphandler that has a similar nature, the state of processing a request is difficult to revert to when it is appropriate to process the next request, or if the recovery is not as good as constructing a new one, then we should design it as not reusable.

I'm doing a no refresh upload control via IFRAME, which includes some httphandler to be able to relate directly to the Axd suffix for path-independent scenarios. One of the HttpHandler I inherited directly from page and wrote as if Aspx+cs compiled code to build the complete control tree in the OnInit phase. This httphandler used to be IIS5 on XP, but it's a problem for Vista IIS7.

First of all, in IIS7 I adopted its new configuration mode, the

Then I use Google search, the results found that forums.asp.net someone raised the exact same problem, he is also using page to do HttpHandler. I think only with page to do HttpHandler people will encounter such a problem, because the general write their own HttpHandler are stateless, so all can be reused. And that post only the administrator replied, "You'd better go to Forums.iis.net to ask." So I went to iis.net search, the results found no one mentioned this problem, so had to go to the forum to ask questions, but no one day to answer, it seems that IIS7 popular before the popularity of iis.net will not rise (IIS7 the default welcome page link to iis.net).

Finally, I chose to use the work around recommended by Jeffrey Zhao, which is to make a httphandlerfactory, which is responsible for returning a new instance of the page each time, and then switching to the httphandlerfactory in the configuration. This solution experiment proved to be feasible, just one more class, do not know how much performance loss. If anyone knows the official solution to the problem, or if there is a better work around, please let me know, thank you.



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.