.Net Core MVC.
In all my views and partial views, I use this line to get its path (url)
<span>@(this.ViewContext.View as Microsoft.AspNetCore.Mvc.Razor.RazorView).Path;</span>
(and also some other lines to get the models name in case its strongly-typed and some other info)
Now, to avoid having to add this code in every view or partial, I have tried to create a partial (_debugPartial.cshtml) with these lines, and then including it in every other view/partial with
<partial name="_DebugInfoPartial" />
But this does not work: I always get the name of this new partial, (“/Views/Shared/_debugPartialchstml”) instead of tha path of the view/partial that is including it…
How could this be achieved?