从.net Core 2.2迁移到.net Core 3.0后中断视图

我将一个ASP.NET Core 2.2 MVC Web应用程序(带有IdentityServer4)迁移到了ASP.NET Core 3.0。现在菜单导航栏不再显示(例如,更改页面,外部登录,两个因素,更改密码等)

我做错了吗?

...

..

ConfigureServices

我替换了

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

与此

        services.AddControllersWithViews();
        services.AddRazorPages();

配置

我替换了

    public void Configure(IApplicationBuilder app,IHostingEnvironment env,ILoggerFactory loggerFactory,IApplicationLifetime lifetime)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            app.UseHsts();
        }

        app.UseStaticfiles();
        app.UseIdentityServer();
        app.UseSession();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",template: "{controller=Home}/{action=Index}/{id?}");
        });

    }

与此

    public void Configure(IApplicationBuilder app,IWebHostEnvironment env,IHostApplicationLifetime lifetime)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            app.UseHsts();
        }

        app.UseStaticfiles();
        app.UseIdentityServer();
        app.UseSession();

        app.UseAuthorization();
        app.UseRouting();
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",pattern: "{controller=Home}/{action=Index}/{id?}");
            endpoints.MapRazorPages();
        });
    }

编辑:这是菜单导航丢失(迁移后)

从.net Core 2.2迁移到.net Core 3.0后中断视图

更新:发现问题,“管理”下的剃须刀页面未加载根“ _layout” 我通过将以下内容添加到_ViewStart

来解决此问题
@{
    Layout = "_Layout";
}

好,那为什么以前能起作用?这很奇怪。

xsa591017 回答:从.net Core 2.2迁移到.net Core 3.0后中断视图

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3139319.html

大家都在问