【问题标题】:Active Directory Roles - developing locallyActive Directory 角色 - 本地开发
【发布时间】:2019-01-29 22:13:55
【问题描述】:

我希望将此本地环境切换为使用 Windows 身份验证,以方便在代码中使用以下逻辑。

User.IsInRole("BRV_Projects_Edit");

我正在使用命令在 Windows 环境中本地启动 dotnet core

"dotnet run"

我的理解是这将启动 Main() 入口点

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>().UseIIS();
}

UseIIS() 是否表明这将在本地启动 IISExpress?这是否意味着我应该能够找到 web.config 来更改身份验证方案?

【问题讨论】:

    标签: asp.net .net iis .net-core kestrel-http-server


    【解决方案1】:

    简而言之,没有。 dotnet CLI 无法启动 IIS Express,因为它不是跨平台的(请参阅 Visual Studio 开发人员社区网站上的 this answer。如果您使用 dotnet run,那么它将在 Kestrel 中托管应用程序

    UseIIS()UseIISIntegration()UseKestrel() 调用使您的应用可以托管在不同的环境中,但对实际启动这些主机没有任何作用。

    实际使用的主机在 launchsettings.json 文件中定义,该文件应该是 Web 应用程序的一部分(在 Visual Studio 解决方案资源管理器的“属性”下)。

    此外,您不需要自己添加UseIIS(),因为它是作为WebHost.CreateDefaultBuilder() 调用的一部分为您完成的。您可以阅读更多关于 CreateDefaultBuilder() 的作用 here

    还有另一个question and answer 可以帮助您从命令行为dotnet 应用程序启动IIS Express。

    如果您想在 IIS 中托管应用程序,那么 instructions are here

    【讨论】:

    • 感谢您的链接。您的跨平台声明阐明了我的观点。通过使用与 Visual Studio Code 相对的 Visual Studio 2017,我可以轻松启动 iisexpress。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 1970-01-01
    • 2017-02-06
    • 2018-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多