dotnet / dotnet/aspnetcore

`RazorFileSystem.GetItem("/").PhysicalPath` obsolete side effects

Open
#64,498 0 comments 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

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

```c#
RazorProjectFileSystem razorFileSystem = webApp.Services.GetRequiredService();
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.