我有一个我在App_Code目录中编写的课程,我可以使用所有普通的aspx页面访问该类,但我似乎无法通过我写的Web服务访问它。我班的一个例子是:
public class User
{
public string login { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string email { get; set; }
}
我的网络服务的一个例子是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
[WebService(Namespace = "https://example.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class example_Service : System.Web.Services.WebService
{
public example_Service()
{
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
我已经尝试过"使用"用户类的命名空间,但它似乎不起作用。我做错了什么?