gpt4 book ai didi

azure - 将 IdentityServer4 Quickstart 部署到 Azure Web 应用程序在索引页上返回 404,但其他路由有效

转载 作者:行者123 更新时间:2023-12-03 18:40:54 24 4
gpt4 key购买 nike

我已经部署了一个根据 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" });
});
}
}
}

程序.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>();
}

Azure Web App 默认文档: enter image description here

包含 Controller 和 View 的整个 MVC 应用程序文件夹结构与快速入门相同。

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

最佳答案

我发现了问题所在 - 很简单,我只是没有注意。当您因某种原因下载快速入门时,它位于主页的 Controller 中:enter image description here很抱歉给您带来不便,并感谢您的帮助:)

关于azure - 将 IdentityServer4 Quickstart 部署到 Azure Web 应用程序在索引页上返回 404,但其他路由有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53821889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com