8

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?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Goyuix
  • 23,614
  • 14
  • 84
  • 128

1 Answers1

20

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";
    }
}
Stobor
  • 44,246
  • 6
  • 66
  • 69
  • 4
    If you fully qualify the namespace+class in the Class= attribute, you need to have the namespace defined around the class definition. – Ryan Shripat Jun 20 '12 at 13:29