locked
WCF constructor on session_start RRS feed

  • Question

  • User49324566 posted

    I have this WCF service where I want to execute some initialization code on the service class, when the ASP.NET application triggers a session_start event. Problem is, WCF services use copies of contracts - not the type itself; so the class consturctor as WCF service does not execute the constructor.  One option would be to configure the service call to use types but that is not a good practice from what I understand.  The other option is to add client constructor on the WCF client class, but that sounds too complicated from what Im trying to do and perhaps not even effective as the code I need to execute is server side.

    Anyhow, I tried to fix this by creating a separate method outside of the constructor.  Problem I'm having is that the session_onstart is being executed twice when I run the ASP.NET app in debug mode.  It gets triggered the second time when the additional method on the WCF clas is called... why is that?  does the call of a WCF method on the session_start triggers a new ASP.NET session?

    In any case, do you know of any work around?

    Thanks for any help

     

    Friday, August 21, 2009 10:31 AM

All replies

  • User-1394244687 posted
    A good example of how to solve your problem is found here: http://social.msdn.microsoft.com/forums/en-US/wcf/thread/447149d5-b44c-47cd-a690-20928244b52b/ Good luck.
    Tuesday, April 5, 2011 11:33 AM