简体   繁体   中英

Hosting WCF service in an existing ASP.Net , Deployment Issue

I am trying to use an already existing ASP.net web application to host a WCF service, so I tried the following steps,

1- In Visual Studio 2010, I created web application through the Web > ASP.net Web Application template, named WebApp .

2- Added new WCF Service through Add > New Item ... > WCF Service , named MyServ .

3- Modified the DoWork() method in MyServ.svc as follows,

From

        public void DoWork()
        {
        }

To

        public string DoWork()
        {
             return "hello";
        }

and consequently I modified IMyServ.cs to match the new signature.

4- When I run the application on development server and visit http://localhost:1399/MyServ.svc , the service runs fine.

5- So I create a publish for this application, to prepare it to be hosted on the IIS.

6- In the IIS, I create a new website named WebAppSite and is given the port 111, so now when I visit http://localhost:111/ , I am directed for the published WebApp site default page, which is fine and shows that the aspx part of the application is working fine on the IIS.

7- So I try to visit http://localhost:111/MyServ.svc to check if the service is successfully deployed, but I get this message,

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Any idea where the problem is?

you need to register the .svc mime type in your IIS

run "\\%windir%\\Microsoft.NET\\Framework\\v3.0\\Windows Communication Foundation\\ServiceModelReg.exe -i"

Here is a full guide, please apply all steps:

  1. Add “.svc” extension and MIME Type as “application/octet-stream” to IIS Mime Type in Features View.
  2. Register Asp.net by running aspnet_regiis.exe -i command from VS 2010 command prompt (Run as admin).
  3. Right click cmd, run as admin, go to “C:\\Windows\\Microsoft.NET\\Framework\\v3.0\\Windows Communication Foundation” folder and run : ServiceModelReg.exe -i

If you did some changes in your IIS, you may need to go to handler mappings, right click on the static file and select "Revert to Parent".

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