将 IdentityServer4 快速入门部署到 Azure Web 应用程序在索引页上返回 404,但其他路由有效

sun*_*ro4 5 azure azure-web-app-service asp.net-core identityserver4

我已经部署了一个从 identityserver4 的快速入门构建的项目(https://github.com/IdentityServer/IdentityServer4.Demo )。只要我在本地运行它,它就可以完美运行,但是当我将它部署到 Azure 时,索引页返回 404,但是当我手动转到其他路由(如“/account/login”)时,它们按预期工作。

我的 Startup.cs:

using System;
using System.Linq;
using System.Threading.Tasks;
using LunchBucks.Auth.Extensions;
using LunchBucksEncryption;
using LunchBucksEncryption.PasswordHashing;
using LunchBucksEncryption.SaltGeneration;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

namespace LunchBucks.Auth
{
    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.AddTransient<ISaltGeneration, SaltGeneration>();
            services.AddTransient<IPasswordHashing, PasswordHashing>();
            services.AddTransient<IEncryptionManagement, EncryptionManagement>();
            services.AddMvc();

            services.AddIdentityServer()
                .AddDeveloperSigningCredential()
                .AddInMemoryApiResources(ApiResourceExtensions.GetApiResources())
                .AddInMemoryClients(ClientExtensions.GetClients())
                .AddInMemoryIdentityResources(ClientExtensions.GetIdentityResources())
                .AddLunchBucksUserStore();

            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy.WithOrigins("http://localhost:3000")
                        .AllowAnyHeader()
                        .AllowAnyMethod();
                    policy.WithOrigins("https://lunchbucks-frontend.azurewebsites.net")
                        .AllowAnyHeader()
                        .AllowAnyMethod();
                });
            });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors("default");

            app.UseIdentityServer();

            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

程序.cs:

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>();
}
Run Code Online (Sandbox Code Playgroud)

Azure Web App 默认文档: 在此处输入图片说明

包含控制器和视图的整个 MVC 应用程序文件夹结构与快速入门相同。

我不知道这里出了什么问题,因为它在本地工作,所以任何帮助将不胜感激:) 提前致谢。

sun*_*ro4 10

我发现了问题所在 - 很简单,我只是没有注意。当您出于某种原因下载快速入门时,它位于主页的控制器中:在此处输入图片说明 很抱歉给您带来不便,感谢您的帮助:)


归档时间:

查看次数:

1387 次

最近记录:

5 年,7 月 前