首页 > 编程语言 >asp.netcore Authentication, schema

asp.netcore Authentication, schema

时间:2022-12-28 14:33:07浏览次数:57  
标签:code asp authenticationScheme will Authentication schemes scheme AddAuthenticati

1.  code  like this will report error:  

builder.Services.AddAuthentication("dd").AddCookie("ddd");
builder.Services.AddAuthorization();

InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action<AuthenticationOptions> configureOptions)

the source code is  AuthenticationService

the exception happen, because the parameter scheme is empty

AuthenticationMiddleware use AuthenticationService

2. the middleware will execute the sentence, which will finally trigger the precede errorcontext.AuthenticateAsync(defaultAuthenticate.Name);

3. Schemes.GetDefaultAuthenticateSchemeAsync(); will return the scheme, so the call is critical

4. if the default scheme is null the method will return null; otherwise, the result will come from a IDictionary<string, AuthenticationScheme>,

the key is authenticationScheme, which come from AuthenticationOptions.schemes;

5.addcookie(schemeName) will call addscheme() which add a schemeName to AuthenticationOptions.schemes. and will add the CookieAuthenticationHandler

6. For each scheme, the important thing is the scheme name and the handler type.








标签:code,asp,authenticationScheme,will,Authentication,schemes,scheme,AddAuthenticati
From: https://www.cnblogs.com/qgbo/p/17010078.html

相关文章

  • asp.net 批量大文件上传下载
    ​ 以ASP.NETCoreWebAPI 作后端 API ,用 Vue 构建前端页面,用 Axios 从前端访问后端 API,包括文件的上传和下载。 准备文件上传的API #region 文件上传......
  • 第7章 使用Razor视图渲染HTML(ASP.NET Core in Action, 2nd Edition)
    本章包括•创建Razor视图以向用户显示HTML•使用C#和Razor标记语法动态生成HTML•使用布局和局部视图重用公共代码RazorPagesPageModel、页面处理程序和Razor视图中......
  • 从CASP12到CASP14的常规目标类别中蛋白质结构预测(protein structure prediction )的顶
    https://doi.org/10.3390/biom12091246 ......
  • asp实现301跳转的方法
    301重定向大家都知道它的好处了,可是,我们如何知道它是301重定向还是302重定向呢?真假301重定向检测方法 先把302重定向的asp代码贴出来:<%ifRequest.ServerVariables("SERV......
  • c#,asp.net 开发 app 学习资料整理
    VS2015ApacheCordova第一个Android和IOS应用 ​​PhoneGap:免费开源的HTML5移动应用开发平台​​ 学习视频材料模板​​​http://www.jqueryfuns.com/​​html5学习资......
  • asp.net下开源项目
    别人收集的开源网站,我来做个总结和整理: 1asp.net下开源项目      2asp.net开源项目3一些asp.netmvc开源项目   4【原】开源项目asp.net     作者:......
  • Asp.net 一些小技巧
    目录部分视图传参cshtml对象转js对象Json过滤部分视图传参1.调用页面@Html.Partial("~/Views/abc/_Defg.cshtml",newViewDataDictionary{{"FromPage","abc"}......
  • 严重漏洞攻击:影响PHP、Java和ASP.NET
    安全研究员AlexanderKlink和JulianWalde发现了一个严重的漏洞,这个漏洞影响到大多数网络服务器。针对这个漏洞的攻击只需要一个HTTP请求,这个特殊设定......
  • ASP.NET 2.0中使用自定义provider (2)
     在teched2005上,有对asp.net2.0的介绍,其中讲到asp.net2.0提供了很多功能,让程序员做少很多东西,这引起了大家的疑惑:asp.net2.0的自定义能力如何?扩......
  • C#使用Aspose将Word\HTML 转换成PDF文件
    写在前面Aspose这个是收费的,直接使用是有水印的需要用到的dll文件==> Aspose.Words.dll、Aspose.HTML.dll、Aspose.Total.lic(授权文件)我使用的是.NETFramework4.0......