相关疑难解决方法(0)

Blazor 允许匿名访问 Razor 页面

我有一个 .net cor 3.1 Blazor 服务器项目。我在这个项目中使用默认的身份系统。我想在不登录的情况下访问特定的剃须刀页面。我怎么做?任何想法?

我尝试添加@attribute [AllowAnonymous]到剃刀页面。但这对我不起作用

_Host.cshtml

page "/"
@using Microsoft.AspNetCore.Authorization
@namespace has.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@attribute [Authorize]
@{
    Layout = null;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>has</title>
    <base href="~/" />
    <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
    <link href="css/site.css" rel="stylesheet" />
    <link href="css/custom_styles.css" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="_content/AntDesign/css/ant-design-blazor.css" rel="stylesheet" />
    <link href="_content/Blazor.ContextMenu/blazorContextMenu.min.css" rel="stylesheet" />
    <script src="_content/BlazorInputFile/inputfile.js"></script>
    <script src="~/js/site.js"></script>
</head>
<body>
    <app>
        <component type="typeof(App)" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-identity asp.net-core blazor blazor-server-side

2
推荐指数
1
解决办法
6115
查看次数