All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASP.NET,Ajax调用WCF服务的代码示例_.net资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/18 7:53:32 Browse times: 359 Comment times: 0

ASP.NET,Ajax调用WCF服务的代码示例_.net资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

ASP.NET Ajax调用WCF服务的代码示例_.net资料_编程技术-你的首页-uuhomepage.com

  本文的主要内容是通过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,将改为

  2、在该项目中添加一个WCF Service,命名为CNBlogsWCFService.svc。

  3、修改App_Code中CNBlogsWCFService.cs的代码:

[ServiceContract(Namespace = "http://www.cnblog.com/")]
  public interface ICNBlogsWCFService
  {
  [OperationContract]
  string AddToFavorites(string blogID, string postID);
  }
  public class CNBlogsWCFService : ICNBlogsWCFService
  {
  public string AddToFavorites(string blogID, string postID)
  {
  return string.Format("收藏成功!BlogID:{0},PostID:{1}", blogID, postID);
  }
  }




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.