日期:2012-09-26  浏览次数:20575 次

作者: 曹勇刚   www.ASPCool.com 时间:2001-11-28 22:51:59  阅读次数:493


     下面我们生成一个web service,起名叫FileServer,在FileServer.asmx中有如下代码:
     
    <%@ WebService Language="c#" Codebehind="FileServer.asmx.cs" Class="useResData.FileServer" %>
     
      大家可以看到Codebehind技术是如何被使用的。在Visual Studio.Net中,自动生成的代码大量使用这样的语句。它使得设计页面和编写代码被划分开了。
     
      在FileServer.asmx.cs中,代码如下:
     
    using System;
     
    using System.Collections;
     
    using System.ComponentModel;
     
    using System.Data;
     
    using System.Diagnostics;
     
    using System.Web;
     
    using System.Web.Services;
     
    using System.IO;
     
    namespace useResData
     
    {
     
     ///
     
     /// Summary description for FileServer.
     
     ///
     
     public class FileServer : System.Web.Services.WebService
     
     {private string rootdir;
     
      public FileServer()
     
      {
     
      //CODEGEN: This call is required by the ASP.NET Web Services Designer
     
      InitializeComponent();
     
      rootdir=Server.MapPath("/caomo/提供传输的文件");
     
      }
     
     
     
      #region Component Designer generated code
     
      ///
     
      /// Required method for Designer support - do not modify
     
      /// the contents of this method with the code editor.
     
      ///
     
      private void InitializeComponent()
     
      {
     
      }
     
      #endregion
     
      ///
     
      /// Clean up any resources being used.
     
      ///
     
     protected override void Dispose( bool disposing )
     
     {
     
     }
     
     public Authentication header; //定义用户身份验证类变量header。
   &nbs