【发布时间】:2012-05-25 22:19:10
【问题描述】:
我正在尝试创建一个简单的 .Net 3.5 页面,其中包含一些 HTML 和 WebMethod。当我尝试从我的浏览器调用我的WebMethod 时,它一直在返回页面。任何想法如何让它工作?
这是我的代码:
<%@ Page Language="C#" Inherits="CFW.WebUI.Page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
[System.Web.Services.WebMethod]
public static string Test()
{
return "Hola!";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
...
</html>
注意:我不使用 Ajax.Net。我只想从客户端调用 WebMethod(使用 jQuery)。
【问题讨论】:
-
考虑使用 asmx 等服务
-
我想把它放在一个文件中。有可能吗?
-
当然,一旦您将它们全部定义在一个文件中。
-
我认为不可能在一个 ASMX 文件中使用 .Net webforms 和 webservices。
标签: c# asp.net .net .net-3.5 webmethod