【发布时间】:2011-12-06 14:17:02
【问题描述】:
我已经将一个 Web 解决方案项目部署到一个 dll 文件中,并且在这个 dll 中我有一个带有 webmethods 的 asmx 文件。我已将此 dll 文件添加到 aspx 页面中,我需要使用 jquery ajax 调用 webmethod。
如果 webmethod 在 dll 中,我该如何调用它?
这是 asmx 文件在 dll 中的样子:
<%@ WebService Language="C#" Class="MyWebServiceWS" %>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class MyWebServiceWS : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public string Helloworld()
{ return "hello" }
}
谢谢,
【问题讨论】:
-
Web 服务如何在用户控件中?您需要更具体并提供代码示例等。
-
只需使用 .ajax() 来调用 jquery .. 在页面或控件上编写 javascript 的天气无关紧要.. 但当您尝试访问页面控件的数据时很重要.. 我用过在我的 ascx 控件上使用了 ajax 调用。'WebService 不是可以嵌入控件的控件'
-
对不起,我的意思是 dll 文件不是用户控件,我添加了 asmx 代码。谢谢!
-
为什么web服务在dll里面?服务器上没有.asmx文件吗?
-
我正在使用自定义框架将 dll 添加到其中。 dll-s 是 Web 部署项目。因此,我希望所有 dll 资源都在 dll 中。
标签: c# jquery ajax web-services