locked
Who can teach me the difference between IIS-Hosting and Self-Hosting for detail? RRS feed

  • Question

  • User-252718598 posted

    Just for the subject, who can give me explaination or some other helpful links? thanks for your in advanced.Smile

    Monday, March 21, 2016 1:45 AM

Answers

  • User36583972 posted

    Hi EastCoder,

    As far as I know, IIS and Self hosting have some differences in the below.

    1: Hosting in Internet Information Services(IIS).

    IIS takes care of creation of service instances, disposal of service instances, recycling and other activities that it does for an ASP.NET website.

    When a request comes in, the ServiceHost is constructed, then the service class being hosted is instantiated, and the request is handled. Nothing needs to be running around the clock. But at the same time, this setup requires more time and effort every time a message comes in, and you as a programmer don’t have much control over your service host.

    2: Hosting in a Console or Desktop application(Self hosting).

    Self hosting has the major benefits of providing our full control. All the control of starting the service, stopping the service and error handling/logging can be done in our host application. The amount of code that needs to be written to self host a Web API service is very small and it is very easy too. Now the decision for choosing self hosting is purely on the requirements of whether or not you want so much control on the service.

    The following MSDN Article, Hosting and Consuming WCF Services probably has all the information you need.

    https://msdn.microsoft.com/en-us/library/bb332338.aspx

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 21, 2016 2:55 AM
  • User36583972 posted

    Hi EastCoder,

    I found the following post in the below may be helpful to you.

    Self hosting or IIS hosted?

    http://forums.asp.net/t/1908235.aspx?Self+hosting+or+IIS+hosted+

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 21, 2016 3:33 AM

All replies

  • User36583972 posted

    Hi EastCoder,

    As far as I know, IIS and Self hosting have some differences in the below.

    1: Hosting in Internet Information Services(IIS).

    IIS takes care of creation of service instances, disposal of service instances, recycling and other activities that it does for an ASP.NET website.

    When a request comes in, the ServiceHost is constructed, then the service class being hosted is instantiated, and the request is handled. Nothing needs to be running around the clock. But at the same time, this setup requires more time and effort every time a message comes in, and you as a programmer don’t have much control over your service host.

    2: Hosting in a Console or Desktop application(Self hosting).

    Self hosting has the major benefits of providing our full control. All the control of starting the service, stopping the service and error handling/logging can be done in our host application. The amount of code that needs to be written to self host a Web API service is very small and it is very easy too. Now the decision for choosing self hosting is purely on the requirements of whether or not you want so much control on the service.

    The following MSDN Article, Hosting and Consuming WCF Services probably has all the information you need.

    https://msdn.microsoft.com/en-us/library/bb332338.aspx

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 21, 2016 2:55 AM
  • User-252718598 posted

    thanks for your cool reply, besides that, what's difference in webapi with above two ways. I have got the difference of the WCF which you provided.Smile

    Monday, March 21, 2016 3:15 AM
  • User36583972 posted

    Hi EastCoder,

    I found the following post in the below may be helpful to you.

    Self hosting or IIS hosted?

    http://forums.asp.net/t/1908235.aspx?Self+hosting+or+IIS+hosted+

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 21, 2016 3:33 AM