【发布时间】:2021-08-18 06:32:56
【问题描述】:
我想使用 Http.sys 启用 Windows 身份验证并使用 POSTman 发送 GET 请求。
我已经输入了我电脑的账号和密码,但是邮递员告诉我这个错误。
不知道发生了什么,谁能告诉我原因?
Configure Windows Authentication in ASP.NET Core
更新
My Purpose
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddAuthentication(HttpSysDefaults.AuthenticationScheme);
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "webwinauth", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "webwinauth v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseHttpSys(options =>
{
options.Authentication.Schemes =
AuthenticationSchemes.NTLM |
AuthenticationSchemes.Negotiate;
options.Authentication.AllowAnonymous = true;
});;
});
邮递员
Setting about NTLM
错误
Error
【问题讨论】:
-
您不能将
Http.sys与asp.net core一起使用,它与ASP.NET Core Module不兼容,并且不能与IIS 或IIS Express 一起使用。 -
您好,请问还有什么可以帮助您的吗?
标签: c# asp.net-core postman windows-authentication http.sys