|
| Problem with handler reload each time after 2 requests. |
 |
Wed, 19 Mar 2008 14:12:48 +000 |
Hi All,
I developped a Handler as following:
public class Handler : IHttpHandler , IRequiresSessionState
{
/// <summary>Manager instance </summary>static protected
internal VDSManager m_manager;
/// <summary>
/// Constructor.
/// </summary>public Handler()
{
m_manager = new VDSManager();
}
#region IHttpHandler Members/// <summary>
/// is reusable
/// </summary>public bool IsReusable
{
get { return true; }
}
/// <summary>
/// send the request to the Handler manager
/// </summary>
/// <param name="context"></param>public void
ProcessRequest(HttpContext context)
{
m_manager.processRequest(context);
}
#endregion
}All work fine, but the only problem is that the IsReusable set to true does
not work well.
Indeed when I perform :
the 1st request the Handler constructor is called and after the processRequest
is called. (normal beahavior)
the 2nd request the processRequest is directly called (normal beahavior)
the 3rd request the Handler constructor is called and after the processRequest
is called. (abnormal beahavior should call directly processRequest)
the 4th request the processRequest is directly called (normal beahavior).
the 5th request the Handler constructor is called and after the processRequest
is called. (abnormal beahavior should call directly processRequest)
the 6th request the processRequest is directly called (normal beahavior).
...
So as you can see My Handler constructor should be called only the 1st time but
in fact when two requests are performed the handler re-call the condtructor.
I do not know what I have to set (maybe in config file or in other way) to
ensure that the constructor is only called the 1st time.
I thank you in advance for your help.
Regards,
Sablis.
|
| Post Reply
|
| Re: Problem with handler reload each time after 2 requests. |
 |
Thu, 20 Mar 2008 09:51:40 +000 |
Hi
the MSDN definition for IsReusable property is :
Gets a value indicating whether another request can use the IHttpHandler
instance.
that doesn't mean the handler will stay there for future requests , it means
that if the Handler currently serving a request and a nother request comes,
then this proeprty will decide if our handler can serve the new request while
serving our original one,
and so if its true , then our handler will serve the new request while serving
our request, false : the handler will refuse the new request until he finishes
our request.
please read this discussion also
http://www.velocityreviews.com/forums/t113975-ihttphandlerisreusable.html
|
| Post Reply
|
| Re: Problem with handler reload each time after 2 requests. |
 |
Thu, 20 Mar 2008 10:39:39 +000 |
Hi
Thanks for your reply.
I ever read the discussion that you proposed to me.
I understand the definition of the IsReusable. The problem is that if I set it
to false the handler is reloaded each time a new request is performed.
So I woul like to load my Handler only one time (the first time that is
called). So it is why I set IsReusable to true. So since It does not work as I
want in setting it true, I am sure that an other problem appears but I do not
know what is it?
So the problem is How to implement the Handler to have the good beaviour (to
improve performances in avoiding reinitialisation of the handler each time)? Is
it possible to obtain this behaviour (maybe not)?
|
| Post Reply
|
| Re: Problem with handler reload each time after 2 requests. |
 |
Thu, 20 Mar 2008 11:02:43 +000 |
Sablis:
So the problem is How to implement the Handler to have the good beaviour (to
improve performances in avoiding reinitialisation of the handler each time)? Is
it possible to obtain this behaviour (maybe not)?
Its not possible as a built in, however if the initialization is so costly ,
and if you get a data from External resources in initialzation, here you need to
cache that data ....
So you need to solve this manually .... to enhance the performance ,
e.g: one solution is to use output caching , so if your handler display images ,
you can set the response cache ability to a specific period of time ,
Hope it helps
|
| Post Reply
|
| Re: Problem with handler reload each time after 2 requests. |
 |
Thu, 20 Mar 2008 11:13:43 +000 |
Ok, I thank you for your precious Help.
I am going to do it in the way that you propose.
|
| Post Reply
|
|
|
|
|
|
|
|
|
|