The easiest (best?) way to render a block property (local block) is to:
@model MediaBlock @Html.PropertyFor(x => x.Content, new { CustomTag = "div" })
Then you also need a view for MediaContentBlock that renders the TestMsg property.
You don't need a controller for blocks either, unless you have some extra data or computing to do to the view model. A controller will just decrease the performance.
The reason you're getting the error is because when you're using EditAttributes (or PropertyFor for that matter) Episerver will look for a view or renderer and then inject that on the page, but since you don't have one for MediaContentBlock an error message is returned instead. Episerver will not re-render the whole page when you make changes to the property, it will just re-render that property.
Episerver doesn't know that you have @Model.Content.TestMsg inside the div with your EditAttributes. That's why the page is only rendered correctly on page load, not when the property is changed.
I wouldn't recommend rendering a block property's properties directly as you have done in your example. Instead render the block property as in my example and then add a view for that block. At least when you want to make the property editable anyway.
We have an issue with block rendering in edit mode.
We have a block which contains another block used as a property (or "local block" as defined by Joel Abrahamsson)
We are using EditAttributes() appropriately in the View to render the edit features in preview mode. However, whenever we do make a change to one of the properties of the local block in preview mode, we're receiving an error message "The block can not be displayed".
We'd expect to be able to make changes to the property in preview mode and see those changes reflect immediately as we've seen this in the past.
For example - our block which references the local block:
The local block:
Bog standard controller:
Bog standard view:
The behaviour is as follows:
1. Create the block and view it in edit mode - the block will render fine at this point.
2. Click on the block edit attribute - change the TextMsg text to something
3. Observe the behaviour: