我想向现有的asp.net 4.0网站(而不是mvc)添加一个wcf的restful服务。我很难找到一个很好的教程,通过添加一个到现有的应用程序/网站。我看到的每个地方都有关于创建新项目的注释(使用wcf restful模板)。 什么是基本步骤?我可以做到这一点没有.svc文件,因为我在.net 4.0?你可以指点我的任何教程?将WCF Restful服务添加到现有的ASP.Net网站
到目前为止,我已经尝试添加一个定义服务合约并使用webinvoke/webget属性的IService.cs和Service.cs类,在本教程中显示的global.asax和web.cong中的服务定义中添加路由http://www.codeproject.com/Articles/255684/Create-and-Consume-RESTFul-Service-in-NET-Framewor但是当我指向localhost/restservice时,我找不到404。
更新: 这是我在我的配置文件中。请注意,这是一个现有的wcf基于soap的服务。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="migrationServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="migrationHttpBinding" maxBufferSize ="104857600" maxReceivedMessageSize="104857600"/>
</basicHttpBinding>
</bindings>
<services>
<service name ="Site.Web.WebService.MigrationService" behaviorConfiguration="migrationServiceBehavior">
<endpoint binding="basicHttpBinding"
bindingConfiguration="migrationHttpBinding"
contract="Site.Web.WebService.IMigrationService"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
您可以发布您的配置文件?此外,你如何托管你的应用程序是在IIS上运行还是在卡西尼上运行? – Rajesh 2012-04-10 15:02:11
它在IIS上运行... – xoail 2012-04-10 15:19:35
请发布您的配置文件,并确保您添加了@Marc_s建议的路由表条目。 – Rajesh 2012-04-10 15:21:35