Skip to content

RazorFileSystem.GetItem("/").PhysicalPath obsolete side effects #64498

@PoseidonEnergy

Description

@PoseidonEnergy

Historically, I've been able to get my project root directory from Razor by using the following line:

RazorProjectFileSystem razorFileSystem = webApp.Services.GetRequiredService<RazorProjectFileSystem>();
Console.WriteLine(razorFileSystem.GetItem("/").PhysicalPath) // c:\path\to\project\root

But, I see that RazorProjectFileSystem is being obsoleted along with Razor runtime compilation.

Is there another way to get the project root directory from Razor? I currently have a Razor page manager class in which it does everything it needs to do without me having to manually give it my project's root directory. Without razorFileSystem.GetItem("/").PhysicalPath, I will have to add another argument to my page manager class's constructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions