Question

I have searched a lot for methods of hosting the WCF and found them to work, however, in my a Solution I have WCF Service Project(it has a web.config with some connection strings) and a ASPX.NET project( it also has a web.config), could any one please clarify on how I can host them in a website.

Thank you.

Was it helpful?

Solution

Do you want any other client to access this WCF service?

If not, just keep a .svc file in your existing web application and use it whenever you need.

If yes, host the WCF project as a website in IIS, console or WAS and refer it from your aspx web application.

OTHER TIPS

For hosting a WCF service you have the following options:

  • WinForms applications
  • Console applications
  • Windows services
  • Web applications (ASP.NET) hosted on Internet Information Services (IIS)
  • WCF services inside IIS 7.0 and WAS on Windows Vista or Windows Server code name "Longhorn"

See here for more information on hosting a WCF service.

For hosting an Asp.Net application I'd recommend using IIS, see here for how. However, using WSE it is also possible to host it as a windows service. See here for how.

Its simple, you just need to add a '.svc' file to your ASPX.net project. e.g. Service1.svc

Then add the following code to the file

<%@ ServiceHost Language="C#" Service="WCFServiceProject.Main" %>

The WCFServiceProject.Main is the fully qualified namespace and name of the class that provides the functionality of your service

You will also need to register the svc extension in IIS for it to work if you haven't already. And don't forget to add the reference to the WCF service project to the aspx.net project.

If you want to create the service dynamically then see my question for some hints Creating wcf service within IIS in code

Just reread the updated (edited) question. You'll need to copy the connection details from the WCF service project into your asp.net project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top