Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.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# Grapevine REST服务器,我无法从其他具有IP或主机名的PC访问_C#_Rest_Http_Server_Grapevine - Fatal编程技术网

C# Grapevine REST服务器,我无法从其他具有IP或主机名的PC访问

C# Grapevine REST服务器,我无法从其他具有IP或主机名的PC访问,c#,rest,http,server,grapevine,C#,Rest,Http,Server,Grapevine,我使用的是VS2012和Grapevine 3.0.4,当时我将Grapevine与localhost一起使用 当然,一切都很顺利。 若我想通过客户端从其他PC进行访问,服务器无法使用主机名ip地址或Computername开始侦听 如果我尝试将服务器pc的主机名设置为localhost,它将开始侦听,但当从具有IP或名称服务器的其他pc到达时,返回错误的请求400 我的代码或库有问题吗 我的服务器代码是 public class embeddedHTTP { private RESTS

我使用的是VS2012和Grapevine 3.0.4,当时我将Grapevine与localhost一起使用 当然,一切都很顺利。 若我想通过客户端从其他PC进行访问,服务器无法使用主机名ip地址或Computername开始侦听

如果我尝试将服务器pc的主机名设置为localhost,它将开始侦听,但当从具有IP或名称服务器的其他pc到达时,返回错误的请求400

我的代码或库有问题吗

我的服务器代码是

public class embeddedHTTP
{
    private RESTServer Server;

    public void ServerStart()
    {
        try
        {
            Server = new RESTServer();
            Server.Port =  GlobalVars.HttpHostPort;
            Server.Host = GlobalVars.HttpHostAdress; // THIS ONLY WORKS FOR LOCALHOST
            Server.MaxThreads = 20;
            Server.Start();

            while (Server.IsListening)
            {
                Thread.Sleep(GlobalVars.HttpHostRespTime);
            }
        }
        catch (Exception ex)
        {
            messenger.logque("embedded HTTP server not started, Error ID : 52", 3, null);
        }
    }

    public void ServerStop()
    {
        Server.Stop();
    }

    public sealed class MyResource : RESTResource
    {    
        //d+$^  [a-zA-Z]+
        [RESTRoute(Method = Grapevine.HttpMethod.GET, PathInfo = @"/")] 
        public void HandleFooRequests(HttpListenerContext context)
        {    
            //String RawuR = context.Request.RawUrl;
            String URL = Convert.ToString(context.Request.Url);
            String ResultXML = brain.HTTPCMD(URL);          
            this.SendTextResponse(context, ResultXML);    
        }    
    }
}

如果无法从远程计算机访问服务器,则可能正在运行防火墙,该防火墙正在阻止到您正在侦听的端口的入站流量。尝试打开防火墙上的端口,看看是否适合您


此外,您还可以通过使用星号(*)作为主机名在所有主机上侦听。

如果您无法从远程计算机访问服务器,您可能正在运行防火墙,该防火墙正在阻止到您正在侦听的端口的入站流量。尝试打开防火墙上的端口,看看是否适合您


此外,您还可以使用星号(*)作为主机名在所有主机上侦听。

更正:VS2015社区版更正:VS2015社区版