Try using the extension method as follows:
public static class HtmlHelperExtensions { public static BeginFormObject BeginForm(this HtmlHelpers helpers, NancyRazorViewBase view) { return new BeginFormObject("<form method=\"post\">", view); } public class BeginFormObject : IDisposable { private NancyRazorViewBase view; public BeginFormObject(string markup, NancyRazorViewBase view) { this.view = view; view.WriteLiteral(markup); } public void Dispose() { view.WriteLiteral("</form>"); } } }
This allows you to use the following syntax in a razor:
@using (Html.BeginForm(this)) { ....other stuff }
source share