作者:十字彩虹00 | 来源:互联网 | 2022-12-02 17:29
我面临此错误,当我使用angularjs在IIS中发布我的应用程序时,请帮助我,请帮助我如何使用.net core 2.1和angularjs解决此错误。在Visual Studio正常工作中,我在IIS中遇到此错误
services.AddSpaStaticFiles(cOnfiguration=>
{
configuration.RootPath = "ClientApp/dist";
});
});
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
错误截图:
1> 小智..:
npm script'start'意味着,.Net Core正在尝试调用ng serve
以在开发环境中运行angular模块。因此,当您将应用程序托管在Azure /本地或任何其他服务器上时,请确保未在开发环境中部署应用程序。
"ASPNETCORE_ENVIRONMENT": "Development"
将其更改为
"ASPNETCORE_ENVIRONMENT": "Production"
。请参考这里
在生产模式下部署后,仍然面临任何其他错误。尝试以下操作找出错误。注释掉Startup.cs中的以下代码块
// if(env.IsDevelopment())// {// spa.UseAngularCliServer(npmScript:“ start”); //}
然后将其部署回开发模式。您将收到真正的错误消息。
可以在ServiceManifest.xml文件中更改该变量。默认情况下未设置。