Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#中的Web服务未显示所有可用方法_C#_Webmethod - Fatal编程技术网

C#中的Web服务未显示所有可用方法

C#中的Web服务未显示所有可用方法,c#,webmethod,C#,Webmethod,我在C#中创建了一个web服务,但它无法显示我在运行该服务时创建的所有方法 这是我的密码: public class Data : System.Web.Services.WebService { public Data() { } [WebMethod] public string getIPAddress() { return Context.Request.ServerVariables["REMOTE_ADDR"];

我在C#中创建了一个web服务,但它无法显示我在运行该服务时创建的所有方法

这是我的密码:

public class Data : System.Web.Services.WebService
{

    public Data()
    {

    }

    [WebMethod]
    public string getIPAddress()
    {
        return Context.Request.ServerVariables["REMOTE_ADDR"];
    }


    [WebMethod]
    public string getDateTime()
    {
        // gets the current date and time in the format Month/Day/Year Hour/Minute/Second
        return DateTime.Now.ToString("MM/dd/yyyy HH:mm:sszzz");
    }
}

<%@ WebService Language="C#" CodeBehind="Data.asmx.cs" Class="Learning_Team_A.Data" %>
公共类数据:System.Web.Services.WebService
{
公共数据()
{
}
[网络方法]
公共字符串getIPAddress()
{
返回Context.Request.ServerVariables[“REMOTE_ADDR”];
}
[网络方法]
公共字符串getDateTime()
{
//获取当前日期和时间,格式为月/日/年小时/分钟/秒
return DateTime.Now.ToString(“MM/dd/yyyy HH:MM:sszzz”);
}
}
它仅在页面上显示getDateTime方法

任何帮助都将不胜感激


谢谢

您需要右键单击服务并在visual studio中更新web服务,然后重试。您需要右键单击服务并在visual studio中更新web服务,然后重试