运行Consent Page

学习分享 丨作者 / 郑 子 铭 丨公众号 / DotNet NB / CloudNative NB

任务21:运行Consent Page

修改 Config.cs 中的 RequireConsent 为 true,这样登录的时候就会跳转到 Consent 页面

修改 ConsentController 的 Index 为异步

[HttpGet]
public async Task<IActionResult> Index(string returnUrl)
{
    var model = await BuildConsentViewModel(returnUrl);

    if (model == null)
    {

    }

    return View(model);
}

构造函数改为 public

public ConsentController

Index.cshtml 添加用户信息和 icon

@if (Model.IdentityScopes.Any())
{
    <div>
        <span class="glyphicon glyphicon-user"></span>
        用户信息
    </div>
    <ul class="list-group">
        @foreach (var scope in Model.IdentityScopes)
        {
            @Html.Partial("_ScopeListitem", scope)
        }
    </ul>
}

_ScopeListitem.cshtml

启动服务端 mvcCookieAuthSample,再启动客户端 MvcClient,登录之后跳转到 Consent 页面

如果界面出现乱码,可将文件 Index.cshtml 与 _ScopeListitem.cshtml 另存为 UTF-8 编码

在 Config 的 GetClients 中补充客户端信息

修改 Index.cshtml,不然看不到图片

再次启动程序,显示如下:

Last updated