ASP.NET MVC(Codeplexで入手可能)のソースを見ると、BeginFormの実装が最終的に次のコードを呼び出すことがわかります。
static MvcForm FormHelper(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary<string, object> htmlAttributes)
{
TagBuilder builder = new TagBuilder("form");
builder.MergeAttributes<string, object>(htmlAttributes);
builder.MergeAttribute("action", formAction);
builder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);
htmlHelper.ViewContext.HttpContext.Response.Write(builder.ToString(TagRenderMode.StartTag));
return new MvcForm(htmlHelper.ViewContext.HttpContext.Response);
}
MvcFormクラスはIDisposableを実装し、disposeメソッドは応答に</form>を書き込みます。
したがって、必要なのは、ヘルパーメソッドに必要なタグを書き込み、IDisposableを実装するオブジェクトを返すことです...disposeメソッドでタグを閉じます。