How does the execution of ASMX web service start?


  • I am working on some existing code. Project contains a ASMX web service. When I run the project (F5), it runs properly and I can see exposed service methods. However I am not able to understand the starting point of execution. I can't find any InitializeComponent/Main/InIt method. How does .net start the ASMX service. Can I debug through it?


    Basically my requirement is to host a WCF service in this project. I have written the code for my WCF service. But I have no idea to where to put the service host initialization and connection open code. Please help me out.

    Monday, October 25, 2010 9:45 PM


All replies

  • Let me try and take a stab at this:

    First of all you need to understand the webservice is always "running" as it is being handled by the web server.

    As for "starting" it in the program. You need to initialize the Webservice by creating a variable to take on the attributes of the webservice such as:

    WebService ws = new WebService();

    and then you can access the methods:



    This is an example of consuming a websrvice that I created for accessing Active Direcotry information.

        private void button1_Click(object sender, EventArgs e)
          itg.ITG_Service i = new itg.ITG_Service();
          i.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
          itg.RtnCode r = new itg.RtnCode();
          itg.ADList a = new itg.ADList();
          itg.UserInformation u = new itg.UserInformation();
          u = i.GetData("simonsf");

    Variables used from the webservice is RtnCode, ADList, and UserInformation.


    Hopefully this will point you in the right direction.



    Tuesday, October 26, 2010 12:44 PM
  • It all depends who hosts the service.

    If IIS host it then your service is just a dll. as such it has no entry point, it is just like another API which the web server calls when it receives a message. Think of System.String - it also has no "entry point". it is just invoked as needed.


    With WCF you have an option to do self hosting. In which case you can debug (some) of the start up:



    Note that either way you should be able to put a breakpoint in the service methods, you do not need to debug the start up for that.

    WCF Security, Interoperability And Performance Blog
    Tuesday, October 26, 2010 9:17 PM