U4-1326 - Html.BeginUmbracoForm() does not render a form in a layout view - v4.11.1

Created by Anthony 16 Dec 2012, 20:16:02 Updated by Anthony 03 Jan 2013, 11:02:50

Html.BeginUmbracoForm() does not render a form in a layout view. Renders fine in a partial.


Sebastiaan Janssen 17 Dec 2012, 14:09:21

I don't think there's a way around this (this is how we need to do it to make BeginUmbracoForm work), Shannon?

Shannon Deminick 27 Dec 2012, 14:43:46

You can use Html.BeginUmbracoForm() anywhere that you like. If you can post your syntax I can show you why it is not working. You are probably building a form in a Partial based on the Partial's 'Model' property but in your layout you probably don't have a 'Model' property the same as what you want to render in your form. MVC does not force you to auto scaffold a form based on a model, it's also hugely flexible in that you can build your form using a number of different ways. If you do want to auto scaffold an entire form or just form fields you can use a custom inline declared model in your view too, it doesn't just need to be the view's 'Model'.

I'm going to close this issue but you can post your syntax here if you like and I can show you how to do it.

That said, its probably wiser to have your form in a partial anyways and if you want to render the form in a layout, then just render the partial containing your form in your layout.

Anthony 02 Jan 2013, 23:43:34

I should have been more descriptive. The issue is to do with the Form tag only rendering it's static markup, but without the surrounding form tag. But it turns out that it's a specific case...

eg. Here is a razor form:

@using (Html.BeginUmbracoForm("Logout", "AccountSurface", FormMethod.Post, new )) { }

Here is the markup that is rendered:

Note the lack of a surrounding form tag.

This is all that was in the layout. I tracked down the issue to this in the parent layout:


This causes the form tag issue when @RenderPage is placed before the @RenderSection. It does not occur when @RenderPage is placed after the @RenderSection.

It was remaining code from a razor script port from Umbraco 4.9. @RenderPage should have been changed to @Html.Partial.

@{Html.RenderPartial("~/Views/Partials/Logout.cshtml");} works just fine

as does:


According to this it shouldnt matter which one is used: http://stackoverflow.com/questions/4501736/razor-html-partial-vs-renderpage

Or is there something about RenderPage that I don't know about?

Shannon Deminick 03 Jan 2013, 02:43:29

TBH I've never heard of or used "RenderPage", it seems to be built in to the WebPages libraries, not the MVC libraries. Not sure right now the entire difference but there are a few articles on it that I'm sure you've found.

What happens if you just do a '@Html.BeginForm' with valid parameters, does the same issue occur? The code that we use in BeginUmbracoForm is near identical to MVC's BeginForm.

Anthony 03 Jan 2013, 10:09:01

Tried and it failed too.

I did a quick google...

Apparently it's a bug in MVC.


"We have fixed this bug in MVC. The fix will be available in the next release of the ASP.NET MVC runtime.".

I don't know what version of MVC the bug fix would have been added to though. The post was mid last year.

Sebastiaan Janssen 03 Jan 2013, 10:54:43

@Anthony we're updating v6 to use MVC4, that should be the fixed version then! :)

Anthony 03 Jan 2013, 11:02:50


Priority: Normal

Type: Bug

State: Closed

Assignee: Shannon Deminick

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version:


Story Points: