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.

Related posts

Recent Viewed