简体   繁体   中英

wcf host console service code to iis7?

I created a console Application which hosts the service... now i want to take the service and host it on iis7

I created the .svc file

configured the iis7

http://i.stack.imgur.com/Ehfhs.jpg

在此处输入图片说明

all the compiled code i put on outside directory :

http://i.stack.imgur.com/k0gAh.jpg

在此处输入图片说明

and the bin file inside the APP code folder...

and it tells me : http://i.stack.imgur.com/B3NKn.jpg

在此处输入图片说明

what am i missing ?

Can i convert console hoster to iis hoster ?

should it have to be website in the first place ?

should the service also need to have the config ( in my console app it didnt - only the hoster).....? ps as you can see i did clone the config here. ( to the service dir) and also to the output dir.

The easiest would be to create a new empty ASP.NET application to which you add a new WCF service. Then simply replace the generated code with the one of your service.

I think the reason why your code doesn't work is because you have an ASP.NET website (and not ASP.NET application) and in your .svc file you are only specifying the name of the service but not the codebehind file that contains it. Since an ASP.NET website is not compiled you need to specify this :

<% @ServiceHost 
    Service="Service.Class1" 
    Debug="Debug"
    Language="C#" 
    CodeBehind="~/App_Code/Class1.cs"
%>

Also you are mentioning some bin file inside the APP code folder . If you have some precompiled service in an assembly, this assembly should be inside the ~/bin folder. In a precompiled ASP.NET application you should not have any App_Code folder. It's really 2 different modes: application vs website. Up to you to decide which mode you prefer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM