ASP.Net Core WebApi前后端发布在一起
将VUE、React、Angular打包好的文件放到ASP.Net Core WebApi的wwwroot目录下
在StartUp中的Configure中配置或者Program中配置
app.UseRouting()
app.UseStaticFiles();
if (!app.Environment.IsDevelopment())
{
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
defaultFilesOptions.DefaultFileNames.Clear();
defaultFilesOptions.DefaultFileNames.Add("index.html");
app.UseDefaultFiles(defaultFilesOptions);
}
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
if (!app.Environment.IsDevelopment())
{
endpoints.MapFallbackToFile("index.html");
}
})