0

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

在此处输入图像描述

而不是它应该是什么样子

在此处输入图像描述

该程序未在.net 6.0上运行,因为它说找不到 /index,但我通过运行 cmds 下载了 IdentityServer4 的模板,dotnet new -i identityserver4.templatesdotnet newis4ui给了我包含/index. 有关 identityserver UI,请参阅此 github因此,我在项目属性设置中将其从 .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,我认为这会有所帮助,但没有。

4

1 回答 1

1

从您提供的屏幕截图中可以看出,没有加载js任何css文件。您必须app.UseStaticFiles()app.UseRouting(). 这将解决问题

于 2021-06-20T05:06:51.823 回答