【发布时间】:2014-03-19 12:18:43
【问题描述】:
我正在编写一个 web 方法来将一个 html 文件返回给 android 客户端 这是我尝试过的代码
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
string file = Server.MapPath("index.html");
return file;
}
}
而且毫无疑问它不起作用,我不确定该方法的返回类型,该选择哪个。 我需要将该html文件转换为字符串然后返回给客户端吗?
【问题讨论】:
-
您是要返回文件的内容,还是文件的URL?
-
我需要将整个html文件下载到客户端,这是一个android设备。
-
ASMX 是一项遗留技术,不应用于新开发。 WCF 或 ASP.NET Web API 应该用于 Web 服务客户端和服务器的所有新开发。一个提示:Microsoft 已停用 MSDN 上的 ASMX Forum。