Unity with ASP.NET Core and MVC6 (Core)

前端 未结 2 621
自闭症患者
自闭症患者 2020-12-04 13:51

Update 09.08.2018
Unity is being developed here but I haven\'t had the time to test how it plays with the ASP.NET Core framework.

Update

2条回答
  •  清歌不尽
    2020-12-04 14:11

    For ASP.Net Core 2.0, 2.1, 2.2, 3.1 and Unity there is official solution available from Unity authors as NuGet package here: NuGetPackage

    Here is Git repository with samples: Git repo

    Usage is very simple (from Git repo homepage):

    public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
           .UseUnityServiceProvider()   <---- Add this line
           .UseStartup()
           .Build();
    

    And here is example with Unity DI for ASP.Net Core.

    I am using this solution in my ASP.Net Core application and works good.

提交回复
热议问题