I hope that title is clear enough.
I have 2 projects, MyProject.Website (ASP.NET MVC3 F开发者_C百科ront End) and MyProject.WcfService. When i host the website, i'd rather not have to host two websites inside of IIS, i'd like to be able to host just MyProject.Website and inside of that reference MyProject.WcfService.
I know i can do this via ServiceHost, which should work, but is there a better way?
Check this post where i demostrated how you can host wcf service dll
Create, Host(Self Hosting, IIS hosting) and Consume WCF servcie
IIS hosting
- To host same WCF library in your application create WCF Web application project using WCF web application.
- Delete the files created in the IService.cs and Service.cs file from App_Code folder
- Include WCF library *.dll file which we created.
Open Service.svc file and modify the single line in it
-- <%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceLibrary.Service1" %>
Change the web service WEB.Config file to to expose service to client. i.e you need to create Same element as listed above in in the app.config file of service library.
精彩评论