x.razor
Code: Select all
@page '\PublicRazor\x'
...
Ich gehe zur x.razor-Seite ohne Anmeldung. In diesem Fall funktionieren keine der Funktionen in x.razor (z. B. Klicken auf eine Schaltfläche oder Formularvalidierung). Als ich die Entwicklerkonsole überprüfte, sah ich Folgendes:

Zweites Szenario
Ich gehe zur Seite x.razor, nachdem ich mich bei der Blazor-App angemeldet habe . In diesem Fall funktionieren alle Funktionen in x.razor ordnungsgemäß. Und die Entwicklerkonsole hat keine Fehler.
Warum passiert das? Wie bringe ich alle Funktionen von x.razor in den aktiven Zustand?
Standard _Host.cshtml
Code: Select all
@page "/"
@using Microsoft.AspNetCore.Authorization
@namespace has.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@attribute [Authorize]
@{
Layout = null;
}
has
Code: Select all
@page "/publicrazor"
@using Microsoft.AspNetCore.Authorization
@namespace has.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@attribute [AllowAnonymous]
@{
Layout = null;
}
has
Code: Select all
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
endpoints.MapFallbackToPage("~/PublicRazor/{**segment}", "/PublicRazor/_Host");
});