Client -Seite, Angualr.json -Datei: < /p>
Code: Select all
Project > MyApp > architect > build > options > index: src/root.html
< /code>
Program.cs
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(System.IO.Directory.GetCurrentDirectory())
.UseIIS()
.UseStartup()
.UseNLog()
.Build();
host.Run();
}
< /code>
startup.cs in der konfigurieren Methode < /p>
app.UseHttpsRedirection();
app.UseHsts();
app.UsePathBase("/api");
app.UseDefaultFiles();
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = context =>
{
context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store");
context.Context.Response.Headers.Add("Expires", "-1");
}
});
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
app.UseRouting();
app.UseCors();
app.UseSaml2();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
< /code>
und in der Methode configureServices: < /p>
services.AddSaml2();
// In production, the Angular files will be served from this directory
if (!Environment.IsDevelopment())
{
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
}
Wenn die App serviert wird, wird es am Root so angezeigt. /> Problem:
Ich versuche, eine 404 -benutzerdefinierte Seite in meinem IIS einzurichten, wenn ein Controller, der nicht existiert, aufgerufen wird, aber das Verhalten, wenn ich so etwas versuche: https: ///root.html#/bogus, der URL wird sofort auf den vorherigen URL zurückgeführt, aber es gibt einen Fehler in der Konsole von Chrome:
Code: Select all
ERROR oe: NG04002: 'bogus'
at Wue.noMatchError (https://myserver/main.js:1:385012)
at https://myserver/main.js:1:385814
at https://myserver/main.js:1:347833
at Sn._error (https://myserver/main.js:1:17455)
at Sn.error (https://myserver/main.js:1:12087)
at Sn._error (https://myserver/main.js:1:12327)
at Sn.error (https://myserver/main.js:1:12087)
at Sn._error (https://myserver/main.js:1:12327)
at Sn.error (https://myserver/main.js:1:12087)
at Sn._error (https://myserver/main.js:1:12327)
< /code>
Ich habe in die Oberseite gesucht und es gibt eine Reihe von Aufrufen dieser Methode: < /p>
error(n) {
this.isStopped ? ve(function gu(t) {
return _u("E", void 0, t)
}(n), this) : (this.isStopped = !0, this._error(n))
}