【问题标题】:Grapevine sample REST server code returns a "Not found" responseGrapevine 示例 REST 服务器代码返回“未找到”响应
【发布时间】:2016-03-09 10:03:23
【问题描述】:

我想使用Grapevine Plus 实现一个简单的 REST 服务器,并遵循wiki 上提供的示例。我通过 NuGet 安装了 Grapevine Plus 3.0.4。我正在运行以下代码,但是当我通过浏览器导航到 http://localhost:1234,或者如果我通过 REST 客户端浏览器插件发送 GET 请求时,我得到的只是 "Not found" 响应:

// Program.cs
static void Main(string[] args)
{
    var server = new RESTServer();
    server.Start();

    Console.WriteLine("Press Enter to Continue...");
    Console.ReadLine();
    server.Stop();
}

// TestResource.cs
public sealed class TestResource : RESTResource
{
    [RESTRoute]
    public void HandleAllGetRequests(HttpListenerContext context)
    {
        this.SendTextResponse(context, "GET is a success!");
    }
}

我错过了什么?

【问题讨论】:

  • 您创建的控制台项目的名称是什么?

标签: c# rest grapevine


【解决方案1】:

由于您编写的代码看起来不错(并且对我来说仍然运行良好),我认为您可能会遇到this project naming issue in Grapevine 3.0.x

这在 3.1.0 版本中不再是问题,但对于较旧的 3.0.x 版本,您需要确保您的程序集名称中没有包含单词“grapevine”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-24
    • 2014-05-31
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 2021-11-26
    • 2016-02-24
    • 2014-08-09
    相关资源
    最近更新 更多