如何在没有代码隐藏文件的情况下创建ASMX Web服务页面

时间:2022-01-29 08:48:18

I have been able to create ASPX pages without the code behind, but I can't for the life of me figure out the magic combination to get an ASMX page to work without a code behind. Is this even possible?

我已经能够创建没有代码背后的ASPX页面了,但我不能为我的生活找出神奇的组合,让ASMX页面无需代码就可以工作。这有可能吗?

1 个解决方案

#1


18  

Quick sample:

<%@ WebService Language="C#" Class="SampleWebService" %>
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SampleWebService : System.Web.Services.WebService
{

    [WebMethod]
    public string Hello()
    {
        return "Hello World!";
    }

    [WebMethod]
    public string DoStuff(out string stuff)
    {
        stuff = "Woohoo!";
        return "OK";
    }
}

#1


18  

Quick sample:

<%@ WebService Language="C#" Class="SampleWebService" %>
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SampleWebService : System.Web.Services.WebService
{

    [WebMethod]
    public string Hello()
    {
        return "Hello World!";
    }

    [WebMethod]
    public string DoStuff(out string stuff)
    {
        stuff = "Woohoo!";
        return "OK";
    }
}