【IT168 技术文档】本文的主要内容是通过ASP.NET Ajax调用WCF(Windows Communication Foundation)服务的代码示例。(ASP.NET Ajax 1.0与3.5都可以调用)
写这篇文章是源于想用ASP.NET Ajax + WCF来改造博客园的收藏功能。
开发环境是:.NET Framework 3.5 Beta 2+Visual Studio 2005。
准备:
1、安装.NET Framework 3.5 Beta 2。
ASP.NET Ajax调用WCF服务需要.NET Framework 3.5 Beta 2中的System.Web.Extensions.dll(3.5.0.0),System.ServiceModel.Web.dll支持。
开始我安装的是.NET Framework 3.5 June 2007 Community Technology Preview (CTP),走了一些弯路。
2、安装Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF)。
3、检查IIS是否有.svc到c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll的映射,如果没有,建立映射,建立时取消“检查文件是否存在”的选择。
开始:
1、在VS 2005中新建一个Web Site项目。
添加web.config,将<authentication mode="Windows" />改为<authentication mode="Forms" />。
2、在该项目中添加一个WCF Service,命名为CNBlogsWCFService.svc。
