I have some code I would like to execute very early in the lifecycle of a call to an ASMX function. For our ASPX pages, this code is in the Page_Init() function on a base class
There isn't really such a thing in an asmx web service, System.Web.Services.WebService has no events. Your best bet is to create a default constructor and put it in there.
e.g.
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
private string strRetVal;
public WebService1()
{
strRetVal = "Hello World";
}
[WebMethod]
public string HelloWorld()
{
return strRetVal;
}
}