i am facing this error please help me this when i publish my app in IIS with angularjs please help me how to solve this error iam using .net core 2.1 and angularjs . In visual studio working fine I am facing this error in 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");
}
});
Error Screenshot:
npm script 'start' means, .Net Core is trying to call ng serve
to
run the angular module in development env. So when your are hosting
your application in Azure/local or any other server, make sure you
have not deployed your application in Development environment.
"ASPNETCORE_ENVIRONMENT": "Development"
Change it to
"ASPNETCORE_ENVIRONMENT": "Production"
. Refer here
After you have deployed in production mode and still facing any other errors. Try the following to find out the error. Comment out the following code block in Startup.cs
//if (env.IsDevelopment()) // { // spa.UseAngularCliServer(npmScript: "start"); // }
and deploy the application back in Development mode. You will get the real error message.
The variable can be changed in the ServiceManifest.xml file. By default it is not set.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseSpaStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
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");
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With