ASP.Net WCF service without App_Code application

I want to create a WCF service for use on my ASP.Net website (and not in a project) that either does not have a code file, which is an option for a traditional asmx style service, but apparently not for wcf services, or which stores its code in a separate code project and is simply displayed in the svc file.

I tried to just move the code file from app_code to a separate project, but could not figure out how to link them, since deleting the codebehind attribute from the svc file immediately causes an error.

+3
source share
2 answers

You can add your SVC file to your web project to the class contained in a separate DLL. You do not have to have the SVC code in your App_Code directory. It is very easy to do. There should be only one attribute for your SVC file - Service. Here is an example of the one I use where I work:

<%@ ServiceHost Service="My.Qualified.Service.Class.Name" %>

I do not have the code in the App_Code folder. All the logic of this SVC is contained in a separate DLL (which happens My.Qualified.Service.Class.dll). The name of my service is the name of the implementation class; that is the only caveat.

My web.config (inside system.serviceModel) refers to this service as follows:

<service name="My.Qualified.Service.Class.Name">
    <endpoint address=""
     binding="webHttpBinding"
     contract="My.Qualified.Service.Class.IName" />
</service>

My service logic is direct WCF code after that. My interface INamedefines my operations; Nameimplements them.

Hope this helps!

+6
source

, , WCF , ( ) , . , .., . , , , - . - DLL- .

http://www.dnrtv.com/default.aspx?showNum=122

0

All Articles