I have multiple angular application inside an asp.net core application. Now I want to set one of them as default. Let say When I run the app, it automatically goto angular home application. Solution structure: SQL-> EntityFrameworkCore->.NET Core->Angular application( HomeApp, App1, App2....)
Right now, after I run the application, I have to go to URL and type : localhost:5000/home Togo to Angular Home application. Otherwise, it won't show anything.
I tried with asp.net core Map and UserSpaStaticFiels.
In each angular app1, app2 index.html file I setup
<base href="/home/">
And in startup.cs the code I setup like this:
<i>
// For each angular application we want to host:
app.Map(new PathString("/home"), home =>
{
if (env.IsDevelopment())
{
StaticFileOptions clienthome = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @"home"))
};
home.UseSpaStaticFiles(clienthome);
home.UseSpa(spa =>
{
spa.Options.SourcePath = "home"; // spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
spa.UseAngularCliServer(npmScript: "start"); // it will use package.json & will search for start command to run
});
}
else
{
// Each map gets its own physical path for it to map the static files to.
StaticFileOptions clienthome = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @"home/dist"))
};
// Each map its own static files otherwise it will only ever serve index.html no matter the filename
home.UseSpaStaticFiles(clienthome);
// Each map will call its own UseSpa where we give its own sourcepath
home.UseSpa(spa =>
{
spa.Options.StartupTimeout = new TimeSpan(0, 1, 30);
spa.Options.SourcePath = "home";
spa.Options.DefaultPageStaticFileOptions = clienthome;
});
}
});
</i>
My expectiation is : asp.net core should run only home application whenever I start visual studio without go to url and tyle localhost:5000/Home.