C
C#2y ago
Butterfly

❔ Registering Angular App that's in IIS to .Net

I have an Angular app that will be hosed in the site/cc. I would like C# to handle deep linking and for other reasons so I need to register that cc virtual directory in IIS . When I use wwwroot , C# recognises the route but when I try to change site/wwwroot/cc to site/cc, it does not work. Is there any reason why wwwroot which is a default static folder is working and others not working? what Did I do wrong?
app.UseSpaStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "cc"))
});

app.MapWhen((context) =>
{
_logger.LogWarning("test", context.Request.Path);
return context.Request.Path.StartsWithSegments("/cc");
},
(ccApp) =>
{
string clientApp1Path = @"cc";

// Each map gets its own physical path for it to map the static files to.
StaticFileOptions clientApp1Dist = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), clientApp1Path)
)
};

// Each map its own static files otherwise it will only ever serve index.html no matter the filename
ccApp.UseSpaStaticFiles(clientApp1Dist);

ccApp.UseSpa(spa =>
{

if (!env.IsDevelopment())
{
spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
spa.Options.SourcePath = "cc";
spa.Options.DefaultPageStaticFileOptions = clientApp1Dist;
spa.Options.DefaultPage = "/cc/index.html";
}
});

});
app.UseSpaStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "cc"))
});

app.MapWhen((context) =>
{
_logger.LogWarning("test", context.Request.Path);
return context.Request.Path.StartsWithSegments("/cc");
},
(ccApp) =>
{
string clientApp1Path = @"cc";

// Each map gets its own physical path for it to map the static files to.
StaticFileOptions clientApp1Dist = new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), clientApp1Path)
)
};

// Each map its own static files otherwise it will only ever serve index.html no matter the filename
ccApp.UseSpaStaticFiles(clientApp1Dist);

ccApp.UseSpa(spa =>
{

if (!env.IsDevelopment())
{
spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);
spa.Options.SourcePath = "cc";
spa.Options.DefaultPageStaticFileOptions = clientApp1Dist;
spa.Options.DefaultPage = "/cc/index.html";
}
});

});
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server