웹 서비스를 호스팅하기 위해 낸시를 사용하려는 콘솔 앱이 있습니다. 여기에 내가 프로젝트 이것을 실행할 때 내 프로젝트 구조 낸시 셀프 호스트 반환 404
입니다
namespace NancyConsole
{
using Nancy;
internal class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = x => View["Views/index.html"];
}
}
}
파일 내 MainModule.cs 여기 내 Program.cs
namespace NancyConsole
{
using Nancy.Hosting.Self;
using System;
internal class Program
{
private static void Main(string[] args)
{
string url = "http://localhost:1234";
var host = new NancyHost(new Uri(url));
host.Start();
Console.WriteLine("Server started, now listening on " + url);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
host.Stop();
}
}
}
내가 어디로 잘못 가고 있는지 모른다. 귀하의 도움을 높이 평가 될 것입니다!
관리자 권한으로 실행 해 보셨습니까? 어쩌면 Vs가 포트를 예약하지 않았을 수도 있습니다. 포트를 예약 했습니까 : netsh http add urlacl url = http : // * : 1234/user = [USER] – MRsa
VS에서 실행되지 않았고 솔루션을 컴파일 한 다음 Debug 폴더로 이동하여 EXE를 관리자로 실행했습니다. – indago
@MRsa 또한 url acls를 설정할 필요가 없도록 RewriteLocalhost = false 옵션을 사용하여 HostConfiguration을 NancyHost 생성자에 전달할 수도 있습니다. 물론 이것은 localhost 만 바인드하고 다른 노드에서 액세스 할 수 없습니다. –