【问题标题】:IdentityServer frontend displaying with missing structureIdentityServer 前端显示缺少结构
【发布时间】:2021-09-04 05:00:22
【问题描述】:

我创建了一个在程序中设置了 identityserver4 的空 asp.net 核心 Web 应用程序。由于某种原因,当我运行程序时,浏览器看起来像这样

而不是它应该看起来的样子

该程序没有在 .net 6.0 上运行,因为它说找不到 /index,但我通过运行 cmds dotnet new -i identityserver4.templatesdotnet newis4ui 下载了 IdentityServer4 的模板,这给了我包含/index 的用户界面。见this github for identityserver UI然后我在项目属性设置中将其从 .net 6.0 切换到 .net 5.0,虽然有效但显示了这种奇怪的格式。

startup.cs

public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddIdentityServer()
                .AddInMemoryClients(Config.Clients)
                .AddInMemoryIdentityResources(Config.IdentityResources)
                .AddInMemoryApiResources(Config.ApiResources)
                .AddInMemoryApiScopes(Config.ApiScopes)
                .AddTestUsers(Config.Users)
                .AddDeveloperSigningCredential();

            services.AddControllersWithViews();

        }

        // 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.UseRouting();

            app.UseIdentityServer();

            app.UseAuthorization();

            app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute());
        }
    }

是否有原因显示它显示在我的第一个屏幕截图中而不是第二个屏幕截图中?我清除了缓存并删除了浏览器上的 cookie,我认为这会有所帮助,但它没有t.

【问题讨论】:

  • 尝试在您的Configure 方法中添加app.UseStaticFiles();
  • 这成功了!谢谢!

标签: asp.net-core asp.net-identity identityserver4


【解决方案1】:

从您提供的屏幕截图中可以看出,jscss 文件均未加载。您必须在app.UseRouting() 之前添加app.UseStaticFiles()。这将解决问题

【讨论】:

  • 谢谢!它确实解决了问题!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-05
  • 2015-04-20
  • 1970-01-01
  • 2018-06-21
  • 2015-10-27
相关资源
最近更新 更多