【问题标题】:How do I convert a ASP.NET method to ASP.NET .asmx web service如何将 ASP.NET 方法转换为 ASP.NET .asmx Web 服务
【发布时间】:2017-05-14 19:50:44
【问题描述】:

我有以下 asp.net 方法,我想将其转换为 .asmx Web 服务。我怎么能做到这一点。请帮忙。

public ActionResult AddCpty(string Id, string Type)
{
    //code for Addcp
    return result;
}

我正在尝试通过在方法顶部放置[WebMethod] 属性来转换它。

[WebMethod]
public ActionResult AddCpty(string Id, string Type)
{
    //code for Addcp
    return result;
}

【问题讨论】:

    标签: c# asp.net web-services web


    【解决方案1】:

    假设您尝试从 ASP 模板中访问它,也许您还没有注册路由?

    See this link 并找到您的路线在项目中注册的位置以公开该方法。

    【讨论】:

      【解决方案2】:

      用静态试试

      [WebMethod] 
      public static ActionResult AddCpty(string Id, string Type) { 
      //code for Addcp return result; 
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-07
        • 2011-03-31
        • 1970-01-01
        • 1970-01-01
        • 2014-09-05
        相关资源
        最近更新 更多