小编S.B*_*dır的帖子

Asp.Net Core 2.1 Windows身份验证。HttpContext.User.Identity.Name在IIS中不起作用

环境:

安装了IIS Express的Windows 10 IIS 10 / Visual Studio 2017社区Windows身份验证安全功能启用了Windows身份验证和启用了基本身份验证并禁用了匿名身份验证

我有一个Asp.Net Core 2.1项目,该项目将在Intranet中工作。所以我需要Windows身份验证。

启动:

 public class Startup
    {
        private IConfigurationRoot _appSettings;
        public Startup(IHostingEnvironment env, IConfiguration configuration)
        {
            Configuration = configuration;
            _appSettings = new ConfigurationBuilder()
             .SetBasePath(env.ContentRootPath)
             .AddJsonFile("appsettings.json")
             .Build();

        }

        private IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            services.AddSession(options => {
                options.IdleTimeout = TimeSpan.FromMinutes(8640); //Sessions Time
            });
            services.AddDistributedMemoryCache();

            services.AddDbContext<PMContext>(); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net iis

5
推荐指数
1
解决办法
2159
查看次数

标签 统计

asp.net ×1

c# ×1

iis ×1