简体   繁体   English

在现有ASP.Net中托管WCF服务,部署问题

[英]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, 我试图使用一个已经存在的ASP.net Web应用程序来承载WCF服务,所以我尝试了以下步骤,

1- In Visual Studio 2010, I created web application through the Web > ASP.net Web Application template, named WebApp . 1-在Visual Studio 2010中,我通过Web > ASP.net Web应用程序模板(名为WebApp)创建了Web应用程序

2- Added new WCF Service through Add > New Item ... > WCF Service , named MyServ . 2-通过添加 > 新建项目... > WCF服务 添加了 新的 WCF服务 ,名为MyServ

3- Modified the DoWork() method in MyServ.svc as follows, 3-修改了MyServ.svc中的DoWork()方法,如下所示:

From

        public void DoWork()
        {
        }

To

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

and consequently I modified IMyServ.cs to match the new signature. 因此,我修改了IMyServ.cs以匹配新的签名。

4- When I run the application on development server and visit http://localhost:1399/MyServ.svc , the service runs fine. 4-当我在开发服务器上运行该应用程序并访问http://localhost:1399/MyServ.svc ,该服务运行良好。

5- So I create a publish for this application, to prepare it to be hosted on the IIS. 5-因此,我为此应用程序创建了一个发布,以准备将其托管在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. 6-在IIS中,我创建了一个名为WebAppSite的新网站,并为其指定了端口111,因此,当我访问http://localhost:111/ ,将定向到已发布的WebApp网站默认页面,该页面正常显示该应用程序的aspx部分在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, 7-因此,我尝试访问http://localhost:111/MyServ.svc以检查服务是否已成功部署,但是我收到此消息,

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. HTTP错误404.3-找不到由于扩展名配置,无法提供您请求的页面。 If the page is a script, add a handler. 如果页面是脚本,请添加处理程序。 If the file should be downloaded, add a MIME map. 如果应下载文件,请添加MIME映射。

Any idea where the problem is? 知道问题出在哪里吗?

you need to register the .svc mime type in your IIS 您需要在IIS中注册.svc MIME类型

run "\\%windir%\\Microsoft.NET\\Framework\\v3.0\\Windows Communication Foundation\\ServiceModelReg.exe -i" 运行“ \\%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. 将“ .svc”扩展名和MIME类型作为“应用程序/八位字节流”添加到“功能”视图中的IIS Mime类型。
  2. Register Asp.net by running aspnet_regiis.exe -i command from VS 2010 command prompt (Run as admin). 通过从VS 2010命令提示符运行aspnet_regiis.exe -i命令来注册Asp.net(以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 右键单击cmd,以管理员身份运行,转到“ C:\\ Windows \\ Microsoft.NET \\ Framework \\ v3.0 \\ Windows Communication Foundation”文件夹并运行: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". 如果您在IIS中做了一些更改,则可能需要转到处理程序映射,右键单击静态文件,然后选择“还原为父对象”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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