Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core ASP.NET Core Blazor通过HTTP托管身份验证_Asp.net Core_Blazor - Fatal编程技术网

Asp.net core ASP.NET Core Blazor通过HTTP托管身份验证

Asp.net core ASP.NET Core Blazor通过HTTP托管身份验证,asp.net-core,blazor,Asp.net Core,Blazor,如何使用HTTP配置AddIdentityServerJwt。在HTTPS上运行时,身份验证工作正常,但在HTTP上运行失败 public void配置服务(IServiceCollection服务) { services.AddDbContext(选项=> options.UseSqlServer( GetConnectionString(“DefaultConnection”); services.AddDbContext(选项=> options.UseSqlServer( GetConn

如何使用HTTP配置AddIdentityServerJwt。在HTTPS上运行时,身份验证工作正常,但在HTTP上运行失败

public void配置服务(IServiceCollection服务)
{
services.AddDbContext(选项=>
options.UseSqlServer(
GetConnectionString(“DefaultConnection”);
services.AddDbContext(选项=>
options.UseSqlServer(
GetConnectionString(“JDE_-EDIConnection”);
services.AddDefaultIdentity(options=>options.SignIn.RequireConfirmedAccount=true)
.AddEntityFrameworkStores();
services.AddIdentityServer()
.addapi授权();
services.AddAuthentication()
.AddIdentityServerJwt();
配置(IdentityServerJwtConstants.IdentityServerJWTBearScheme,选项=>
{
options.RequireHttpsMetadata=false;
options.IncludeErrorDetails=true;
});
services.AddTransient();
//services.AddControllersWithViews();
services.AddControllersWithViews().AddNewtonsoftJson(选项=>
options.SerializerSettings.ReferenceLoopHandling=Newtonsoft.Json.ReferenceLoopHandling.Ignore);
services.AddRazorPages();
}
public void配置(IApplicationBuilder应用程序、IWebHostEnvironment环境、AppDbContextSeed播种机)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseWebAssemblyDebugging();
}
其他的
{
app.UseExceptionHandler(“/Error”);
//默认的HSTS值为30天。您可能希望在生产场景中更改此值,请参阅https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//app.UseHttpsRedirection();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
app.UseAuthentication();
app.UseAuthorization();
seeder.SeedAdminUser();
app.UseEndpoints(端点=>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
MapFallbackToFile(“index.html”);
});
}

网上有很多教程和视频,请先搜索并尝试。如果您遇到问题,请在此处询问您尝试过的任何代码。感谢@Umair的更新。这是我通常做的第一件事!在下面,您可以找到我到目前为止尝试过的内容:services.AddIdentityServer().AddApiAuthorization();services.AddAuthentication().AddIdentityServerJwt();Configure(options=>{options.RequireHttpsMetadata=false;});我想问,这是否只是为了当地的发展?任何对任何安全资源的访问都应该通过httpsLet发布
Startup.cs
Thx的所有内容进行更新!这实际上是为了部署,因为应用程序将在内部部署在intranet站点中,所以这只是为了避免自签名证书带来的麻烦。客户端没有集中管理证书的AD,因此必须在每个客户端上手动安装证书。可行,我只是想避免!