我有一个控制器,我在构造函数中注入一个服务接口.该服务还将接口注入其构造函数中.IoC容器(Unity)在构造为给定接口返回的类之一时需要使用有关用户的信息.
发生的事情是,在评估[Authorize]属性并验证用户之前,控制器正在实例化.这迫使Unity执行依赖注入并在用户登录之前使用有关用户的信息.当我们使用集成的Windows身份验证时,这都不是问题,但现在我们使用OpenID Connect到Azure AD并且用户信息不是'直到他们登录为止(在控制器实例化后发生).
我听说(在其他帖子中)有一种方法可以配置我的owin启动类以在过程的早期移动身份验证,但我找不到任何关于如何执行此操作的示例.我需要在实例化控制器之前进行身份验证.
这是我所拥有的简化示例......
控制器:
[Authorize]
public class MyController : Controller
{
    private readonly IMyService myService;
    public MyController(IMyService myService)
    {
        this.myService = myService;
    }
    // ...
}
Run Code Online (Sandbox Code Playgroud)
Unity配置:
public class UnityBootstrap : IUnityBootstrap
{
    public IUnityContainer Configure(IUnityContainer container)
    {
        // ...
        return container
            .RegisterType<ISomeClass, SomeClass>()
            .RegisterType<IMyService>(new InjectionFactory(c =>
            {
                // gather info about the user here
                // e.g.
                var currentUser = c.Resolve<IPrincipal>();
                var staff = c.Resolve<IStaffRepository>().GetBySamAccountName(currentUser.Identity.Name);
                return new MyService(staff);
            }));
    }
}
Run Code Online (Sandbox Code Playgroud)
OWIN启动(Startup.Auth.cs):
public void ConfigureAuth(IAppBuilder app)
{ …Run Code Online (Sandbox Code Playgroud) 我在Visual Studio 2013中使用ReSharper 10.0.2.在我的单元测试会话窗口中,对于类名称,窗口中用于测试失败的文本非常暗.我无法找到设置来更改此设置.我不记得在ReSharper 9中它是这样的.
我的 Azure DevOps 存储库中有一个 Markdown 文件。该文件有一个使用标题锚点的目录:
- [1. Abstract](#1.-abstract)
- [2. Table of contents](#2.-table-of-contents)
- [3. Introduction](#3.-introduction)
  - [3.1. Recommended reading](#3.1.-recommended-reading)
## 1. Abstract
...
## 2. Table of contents
...
## 3. Introduction
...
### 3.1. Recommended reading
Run Code Online (Sandbox Code Playgroud)
这些链接适用于 VS Code 和我使用的任何其他编辑器。在 Azure DevOps 中,导航到文件并选择预览时,标题锚点将呈现为 Azure DevOps 工作项链接:
有没有办法使用标题锚点而不将其链接到 Azure DevOps 中的工作项?