0
我試圖將ASP.NET Core應用程序實現爲Windows服務。我基本上遵循here概述的步驟。我發佈應用程序,然後在發佈位置創建指向可執行文件的服務。該服務已成功創建。我開始這項服務,這也是成功的。但是,當我嘗試將瀏覽器導航到設置的URL時,出現「500 - 內部服務器錯誤」。我對這個過程很陌生,我不知道如何跟蹤這個過程。這是我如何設置我的切入點:作爲Windows服務運行的ASP.NET Core獲取500內部服務器錯誤
public static void Main(string[] args)
{
var isDebug = Debugger.IsAttached || args.Contains("--debug");
string runPath = isDebug ?
Directory.GetCurrentDirectory() :
Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(runPath)
.UseWebRoot(Path.Combine(runPath, "wwwroot"))
.UseUrls(new string[] { "http://myserver:9191" })
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
if (isDebug)
{
host.Run();
}
else
{
host.RunAsService();
}
}
僅供參考,我一直有和沒有UseWebRoot線試了一下,我已經試過UseWebRoot既相對和絕對路徑。任何人都可以將我指向正確的方向嗎?需要更多信息?
謝謝! Dennis
結帳此主題https://github.com/aspnet/Home/issues/1386 –
如果500錯誤,請參閱[如何使用ASP.NET Core顯示錯誤]( http://stackoverflow.com/questions/24563493/how-to-display-errors-with-asp-net-core) –
謝謝Alex!錯誤似乎是「視圖」索引「找不到」。所以它沒有找到那個內容。我查看了我的發佈位置,果然,視圖文件不在任何位置。我可能會錯過某種設置或配置來獲取我的視圖文件發佈(或複製到wwwroot也許)? – Dennis