一、.Program.cs文件裏要使用UseUrls指定啓動url
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(args)
.UseUrls("http://0.0.0.0:8000")//Linux環境部署時使用,對IIS無影響
.UseStartup<Startup>();
}
二、.Linux大小寫敏感,注意網頁文件名、後綴名大小寫
示例:
首頁文件名爲Index.html
Windows環境IIS部署時候訪問首頁,Index.html或者index.html都是可以的
http://192.168.200.129:8000/Index.html
或者
http://192.168.200.129:8000/index.html
但是在Linux環境下,必須和文件名一致,訪問首頁只能使用
http://192.168.200.129:8000/Index.html
三、.文件路徑分隔符
Linux文件路徑分隔符爲/ ,windows的文件路徑分隔符爲\
Windows環境下文件路徑分隔符大部分時候/和\是可以混用的,都能正確識別路徑
Linux環境下文件路徑分隔符只能使用/,如果使用\會出現路徑找不到的錯誤