简体   繁体   English

Asp.net核心应用程序中无法正常工作的索引方法

[英]Not working index method in Asp.net core application

After long fight to publish my asp.net core app to webserver I finally did it and now everything working beside index method from admin controller which is specified as default. 经过长时间的努力,将我的asp.net核心应用发布到Web服务器之后,我终于做到了,现在一切都在管理控制器的索引方法(指定为默认值)旁边工作。

 public IActionResult Index(int page = 1)
    {
        ViewBag.Title = "Admin Panel";

        var model = new AdminViewModel()
        {
            Paging = new PaginationSettings()
            {
                ItemsPerPage = 4,
                CurrentPage = page,
                ShowFirstLast = true,
                TotalItems = _newsData.GetAll().Count()
            },
            Category = _newsData.GetAllCats()

        };
        model.Newses = _newsData.Pagination(page);


        return View(model);
    }

Browser only throwing 500 error and saying that the website is not working. 浏览器仅抛出500错误,并说该网站无法正常工作。 If anybody know what to do pleas reply. 如果有人知道该怎么做,请答复。 //Edit: This is error from logfile: //编辑:这是日志文件中的错误:

warn: Microsoft.Extensions.DependencyInjection.DataProtectionServices[59] Neither user profile nor HKLM registry available. 警告:Microsoft.Extensions.DependencyInjection.DataProtectionServices [59]用户配置文件和HKLM注册表均不可用。 Using an ephemeral key repository. 使用临时密钥存储库。 Protected data will be unavailable when application exits. 当应用程序退出时,受保护的数据将不可用。 warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50] Using an in-memory repository. 警告:Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository [50]使用内存中的存储库。 Keys will not be persisted to storage. 密钥将不会持久存储。

This is a bug in IIS, and it occurs when an application using DataProtection is hosted in the Kestrel/IIS combination. 这是IIS中的错误,当在Kestrel / IIS组合中托管使用DataProtection的应用程序时,会发生此错误。 It's putting your ephemeral keys into memory instead of the machine registry, which means they all get disposed when the app pool stops. 它会将您的临时密钥而不是计算机注册表存储在内存中,这意味着它们在应用程序池停止时都会被丢弃。

There is more discussion about this bug here . 有一个关于此错误的更多的讨论在这里 The problem seems to be solved by running this PowerShell script on the server. 该问题似乎可以通过在服务器上运行此PowerShell脚本来解决。 You can read a bit more about the script in this GitHub thread . 您可以在此GitHub线程中阅读有关脚本的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Post方法在ASP.NET Core中不起作用 - Post Method is not working in ASP.NET Core ASP.NET Core 应用程序的 Configure 方法中是否有强制的语句顺序? - Is there a mandatory order of statements in the Configure method of a ASP.NET Core application? 重定向到另一个网站在 ASP.NET Core Web 应用程序中不起作用 - Redirect to another website is not working in ASP.NET Core Web Application Cookie 身份验证在 ASP.NET Core 应用程序中不起作用 - Cookie authentication is not working in ASP.NET Core application ASP.NET 内核 - 注册应用程序关闭不起作用 - ASP.NET Core - Registering for Application Shutdown isn't working Application Insights 开发人员模式在 ASP.NET 核心 3.1 中不起作用 - Application Insights Developer Mode not working in ASP.NET Core 3.1 平均方法首先无法运行asp.net核心代码: - Average method not working asp.net core code first: ASP.NET Core MVC应用程序洞察在升级到.NET Core 1.1.1后停止工作 - ASP.NET Core MVC application insights stopped working after upgrade to .NET Core 1.1.1 ASP.NET Core 中的应用程序启动代码 - Application startup code in ASP.NET Core ASP.Net Core 应用程序中 LocalAppData 的路径 - Path to LocalAppData in ASP.Net Core application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM