How to move Areas folder to subfolder in DotNet Core 5 with mvc

Hossein Dabbaghan 21 Reputation points
2021-02-18T10:43:50.98+00:00

I moved 'Areas' folder to this 'ControlPanel'. When I run project, get this error:

InvalidOperationException: The default Identity UI layout requires a partial view '_LoginPartial' usually located at '/Pages/_LoginPartial' or at '/Views/Shared/_LoginPartial' to work. Based on your configuration we have looked at it in the following locations: /Areas/Identity/Pages/Account/_LoginPartial.cshtml /Areas/Identity/Pages/_LoginPartial.cshtml /Areas/Identity/Pages/Shared/_LoginPartial.cshtml /Areas/Identity/Views/Shared/_LoginPartial.cshtml /Pages/Shared/_LoginPartial.cshtml /Views/Shared/_LoginPartial.cshtml. Microsoft.AspNetCore.Identity.UI.V4.Pages.Internal.Areas_Identity_Pages__Layout.<ExecuteAsync>b__42_1().

could you please help me to move my Areas folder to subfolder named 'ControlPanel'?

Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
610 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,252 questions
{count} votes

Accepted answer
  1. Yihui Sun-MSFT 801 Reputation points
    2021-02-19T12:02:01.693+00:00

    Hi @Hossein Dabbaghan ,

    I suggest you use Areas. Because it is an ASP.NET feature used to organize related functionality into a group as a separate.

    When a partial view is referenced by name without a file extension, the following locations are searched in the stated order(MVC):
    ▶/Areas/<Area-Name>/Views/<Controller-Name>
    ▶/Areas/<Area-Name>/Views/Shared
    ▶/Views/Shared
    ▶/Pages/Shared
    If you use partial views like this:

    <partial name="_LoginPartial"/>  
    

    When you move the folder where _LoginPartial is located, the corresponding view will not be found.

    You can click on the links below to help you understand:

    1. Areas in ASP.NET Core
    2. Partial view discovery

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Best Regards,
    YihuiSun

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Duane Arnold 3,211 Reputation points
    2021-02-18T18:12:37.303+00:00

    Login should be at the spot you moved it from. All users should be coming to and accessing the login page, that shouldn't be in an Area. The error message is clearly telling you that.

    0 comments No comments