내 코드 :는 낸시 자체 호스팅에 간단한 GET 요청을 수행 할 수 없습니다 : RuntimeBinderException 및 ViewNotFoundException
public class MyWebService : IDisposable
{
private readonly NancyHost _host;
public MyWebService(int port = 7017)
{
var uri = new Uri(string.Format("http://localhost:{0}", port));
_host = new NancyHost(uri);
_host.Start();
}
public void Dispose()
{
if (_host != null)
{
_host.Stop();
_host.Dispose();
}
}
}
internal class MyWebModule : NancyModule
{
public MyWebModule()
{
Get["/"] = _ => "Received GET request";
}
}
HTTP 요청 다음 실행 : Insomnia REST client을 사용 GET http://localhost:7017/
를 내가지고있어 다음과 같은 비밀 예외 :
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Cannot convert type 'Nancy.ErrorHandling.DefaultStatusCodeHandler.DefaultStatusCodeHandlerResult' to 'Nancy.Response''
at CallSite.Target(Closure , CallSite , Object)
출처 : Anonymously Hosted DynamicMethods Assembly
이어서
Nancy.ViewEngines.ViewNotFoundException
at Nancy.ViewEngines.DefaultViewFactory.GetRenderedView(String viewName, Object model, ViewLocationContext viewLocationContext)
예외적 인 추가 정보없이
그런 다음 REST 클라이언트는 404
오류를 표시합니다.
무엇을 잘못 정의 했습니까? 다음 예제를 따라했습니다 : building-a-simple-http-server-with-nancy