How to expose restful interface from windows service ?

后端 未结 2 568
温柔的废话
温柔的废话 2021-01-17 03:33

I wrote a wcf service that expose restful interface.
Now i using the iis as the wcf service host.

There are some action that i need to make on my application be

2条回答
  •  一整个雨季
    2021-01-17 04:05

    To be able to run the app in 2 different host models, you have to separate hosting stuff from you main code. The key point of it: you can use controllers created in the other library project.

    I did this before:

    1. Create a library project and move all you controllers and other classes there.
    2. Create empty WFC service, add reference to the lib above and make it working.
    3. Create an empty console app, reference to the lib, add self hosting stuff and make it working.
    4. Add topshelf package to console app to be able to install it as windows service.

    So you will get:

    1. building and deploying WCF project you can host it in IIS;
    2. building a console app you can run it as console app;
    3. using topshelf install param you can install a console app as windows service.

提交回复
热议问题