如何用C#编制一个WEB SERVER???有没有相关资料,或给个思路,现在虽然已经可以解析ASPX文件,但是URL中传参和FORM 都还不行,还有编码的问题,不知道大家有没有碰到过!!!

解决方案 »

  1.   

    你可以参考一下开元项目castle里面的web服务器
      

  2.   

    你找个身边的人 给你操作一下  10分钟内 搞定----------------------------或者按照向导操作就可以了-----------------------------.net web service 还是很方便的
      

  3.   

    WEB SERVER ???  )_(
      

  4.   

    1.打开 vs 文件->新建->项目->asp.net web 服务
    2.点击项目右键->添加->添加Web服务
    3代码如下 例添加一个叫 TEST.ASMX 的服务
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Web;
    using System.Web.Services;namespace WebServertest
    {
    /// <summary>
    /// User_Info 的摘要说明。
    /// </summary>
    public class Test: System.Web.Services.WebService
    {
    /// <summary>
    /// Test 构造函数
    /// </summary>
    public Test()
    {
    //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
    InitializeComponent();
    } #region 组件设计器生成的代码

    //Web 服务设计器所必需的
    private IContainer components = null;

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if(disposing && components != null)
    {
    components.Dispose();
    }
    base.Dispose(disposing);
    }

    #endregion // WEB 服务示例
    // HelloWorld() 示例服务返回字符串 Hello World
    // 若要生成,请取消注释下列行,然后保存并生成项目
    // 若要测试此 Web 服务,请按 F5 键
    /// <summary>
    /// 获取测试信息
    /// </summary>
    /// <param name="TestString">测试字串</param>
    /// <returns>返回测试字串</returns>
    [WebMethod]
    public string GetTestString(string TestString)
    {
    return TestString;
    }

    }
    }4.GetTestString 就是你这个WebServer的一个公开方法以供其他程序调用
      

  5.   

    新建->项目->asp.net web 服务
    点击项目右键->添加->添加Web服务在Web服务方法前加上[WebMethod]即可以向外发布!
      

  6.   

    你说的这个应用需要在构建好WebService后,发布WebService的时候,将WebService编译为代理类,然后修改代理类中的代码,就可以达到传递参数,或者进行额外处理的目的。
    将WebService编译为代理类,需要用到WSDL.exe这个工具。编译命令如下:
    C:\Documents and Settings\Administrator>"D:\Microsoft Visual Studio .NET 2003\SD
    K\v1.1\Bin\wsdl.exe" /out:c:\aaa.cs http://localhost/Read/CompanyService.asmx?wsdl编译后可以形成代理类,将代理类发给客户机,客户机通过代理类可以和服务器通信。
    代理类的URL部分代码如下:
    。。
    /// <res/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="FDAServiceSoap", Namespace="http://tempuri.org/")]
    public class WSSentToFDA : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        /// <res/>
        public WSSentToFDA() {
    //原始的代码是:this.Url = http://***/Read/CompanyService.asmx;
    //下面是修改后的代码,从XML文件中读出URL地址。
    ReadVersion.AccountManage.ReadXmlFiles rd = new ReadVersion.AccountManage.ReadXmlFiles();
    string s = rd.ReadIPAddress("xiangshan");
    if( s!="no")
    this.Url = s;
    else
    this.Url = "" ;
        }。如果要通过构造函数传参数。则如下:
    public class WSSentToFDA : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        /// <res/>
        public WSSentToFDA(string strUrl) {     this.url=strUrl;
    }.....
      

  7.   

    我现在还不搞清楚楼主的意思,楼主是要自己做一个Web服务器,还是就一个WebService服务程序啊..
      

  8.   

    是这样的,我们要做个产品是给网吧用的,网吧内部服务器上安装我们的产品后,就可以在客户机上通过浏览器来访问网吧服务器上的一个网站.因为考虑让网吧管理人员装IIS和配制站点,可能有困难所以想在程序中加入一个WEB服务程序,只要求能解析ASPX和URL中可以传参还有FORM可以提交就可以了!!!不知道这样说大家是否明白我的意思!!!
      

  9.   

    我要的是个类拟IIS的WEB服务器!!!
      

  10.   

    哈哈!使用IIS就行啊!,将IIS的一些功能通过网页实现不就行了。
      

  11.   

    搜一下codeproject还是多的
    http://www.codeproject.com/cs/internet/mywebserver.asp