Reputation: 5588
I am trying to write an extension method which will be used inside a razor view to get the file path to said view.
I have tried putting the extension method on HtmlHelpers<T>
and NancyRazorViewBase
but cannot seem to get the correct information from the view or from the render context e.g.
public static string GetPath(this NancyRazorViewBase view)
{
//Is null, expecting something like C:\app\views\index.cshtml
return view.Path;
}
<input type="hidden" value="@this.GetPath()"/>
Is it possible to get the path to the current view from inside the view?
I am using Nancy 0.23.
Upvotes: 0
Views: 245
Reputation: 5588
I had overlooked the properties on NegotiationContext
e.g. view.RenderContext.Context.NegotiationContext.ViewName
.
Upvotes: 1