Невозможно заставить Identity Server запустить домашнюю страницу по умолчанию - PullRequest
0 голосов
/ 15 ноября 2018

Я учусь по коду, написанному на APS.Net Core v1, по настройке сервера идентификации, и я использую v2, включая код QuickStart для Identity Server. У меня есть индексная страница по умолчанию для настройки Home Controller, которая поставляется с кодом быстрого запуска. Я считаю, что этот код запускает консоль, но не веб-страницу.

   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)
        {
            var url =
                @"C:\Users\xxxx\Documents\Visual Studio 2017\Projects\SIR\SIR.OAUTH\SIR_SSL_Certificate.pfx";
            services.AddIdentityServer()
                .AddSigningCredential(new X509Certificate2(url, "xxxxxxxx"))
                .AddTestUsers(InMemoryConfiguration.Users().ToList())
                .AddInMemoryClients(InMemoryConfiguration.Clients())
                .AddInMemoryApiResources(InMemoryConfiguration.ApiResources());
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();
            app.UseDeveloperExceptionPage();
            app.UseIdentityServer();
            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
    }

Строка app.UseMvcWithDefaultRoute(); выполнена, но страница индекса не запущена. Что я делаю не так?

РЕДАКТИРОВАТЬ: Это консольный журнал, как было запрошено в комментарии; enter image description here

1 Ответ

0 голосов
/ 16 ноября 2018

Я действительно надеюсь, что это работает, потому что я столкнулся с той же проблемой ранее в этом году.Я должен был поставить мой services.addMVC/configure.addMVC вверху сервисов и внизу вызовов методов.Вот пример:

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //mvc  //-------------------------->HERE!!!!!!!!!!
            services.AddMvc();

            //add indentity server
            services.AddIdentityServer()
                .AddDeveloperSigningCredential()
                .AddTestUsers(Config.GetUsers())//<---gets from static method in Config class
                .AddInMemoryIdentityResources(Config.GetIdentityResources())//<-method in Config class
                .AddInMemoryApiResources(Config.GetApiResources()) //PASS In api res list frm cnfg
                .AddInMemoryClients(Config.GetClients());//--Config getClients()





        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILoggerFactory lf)
        {
            //loggerfactory
            lf.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //call iden4
            app.UseIdentityServer();
            app.UseAuthentication();// just added 1-22 18
            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
            app.UseMvc();  //---------------------------------------->HERE!!!
        }
    }
...