0
votes

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.

 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. 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. 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. Keys will not be persisted to storage.

1
Have you tried debugging your code? - agfc
Post the error message from the log file. Without it, its hard to help you - Tseng
Is your view in the publish folder? - Fabricio Koch
If you put the "Index" at url, works? - Rafael Ribeiro
@RafaelRibeiro no it doesn't, the View folder is in publish project - Tomz Re

1 Answers

0
votes

This is a bug in IIS, and it occurs when an application using DataProtection is hosted in the Kestrel/IIS combination. 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. You can read a bit more about the script in this GitHub thread.