Oops.. Posted one of the links twice. Was supposed to be this one:
http://world.episerver.com/Modules/Forum/Pages/thread.aspx?id=62993
I'm guessing that you probably should be returning a view, not a partial view.
No, that's not it. Like I said, the Index action is never called. So what I return doesn't matter..
Could it be that you have some global action filter that is cancelling the Index action??
Well, I have one custom action filter registered + one for System.Web.Mvc.HandleErrorAttribute. The OnActionExecuting method of my custom action filter is called a bunch of times, but it eventually stops getting called (probably a lot of EPiServer things going on in the background). I've tried commenting out the registration of both actionfilters. No luck, so I don't think that's the problem. Good suggestion though - I hadn't thought of that possibility..
If you attach a debugger and selects all templates registered for the block type, what do you get back? Especially is your PreviewController in the list. Are there any other renderers of type MvcController or WebFormsPage.
You could get all templates for a model by calling:
var templates = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<TemplateModelRepository>()
.List(typeof (LinkBlock));
It finds the PreviewController and it has TemplateTypeCategory set to MvcController.
I don't know how easy it is to see from this, but here's the template variable expanded in the debugger:
- templates {EPiServer.DataAbstraction.TemplateModel[1]} System.Collections.Generic.IEnumerable<EPiServer.DataAbstraction.TemplateModel> {EPiServer.DataAbstraction.TemplateModel[]}
- [EPiServer.DataAbstraction.TemplateModel[]] {EPiServer.DataAbstraction.TemplateModel[1]} EPiServer.DataAbstraction.TemplateModel[]
- [0] {EPiServer.DataAbstraction.TemplateModel} EPiServer.DataAbstraction.TemplateModel
AvailableWithoutTag false bool
Default false bool
Description null string
DisplayName null string
Inherit true bool
Inherited true bool
IsReadOnly true bool
Name "PreviewController" string
Path null string
+ Tags {string[1]} string[]
+ TemplateType {Name = "PreviewController" FullName = "BWG.Intern.Web.Controllers.PreviewController"} System.Type {System.RuntimeType}
TemplateTypeCategory MvcController EPiServer.Framework.Web.TemplateTypeCategories
+ Non-Public members
That looks correct.
If you open up a console window in your browser, do you see any javascript errors when selecting to edit the block?
Could the "Path" field in the template variable above have something to do with it? It's set to null..
I just encountered the same issue. Turns out my layout expected a different model than the preview-view, hence the error.
I know this is an old post, but I feel this should be here in case someone else hit this post while looking for a soution to the same error.
I have a solution in where I use some shared blocks that can be put into ContentArea. Everything works fine, even in edit mode, except for one thing: When I create a new block or try to edit one I get the following exception:
Content with id '237_394' is of type 'Castle.Proxies.LinkBlockProxy' which does not inherit required type 'EPiServer.Core.PageData'
Some google searches pointed me towards making a PreviewController that inherits from IRenderTemplate<BlockData>, but none of the solutions I could find have worked so far. These are the different controller types I have tried (and permutations of them):
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=64223
http://joelabrahamsson.com/pattern-for-episerver-block-preview-mvc-controller/
http://joelabrahamsson.com/pattern-for-episerver-block-preview-mvc-controller/
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=64774&epslanguage=en
Here's a codesample from Joel Abrahamsson that I have tried with no luck:
[TemplateDescriptor(Inherited = true,
Tags = new []{RenderingTags.Preview},
TemplateTypeCategory = TemplateTypeCategories.MvcController)]
public class PreviewController : Controller, IRenderTemplate<BlockData>
{
public ActionResult Index(IContent currentBlock)
{
return PartialView(currentBlock);
}
}
Something is being registered, because with this in my code, I can no longer edit or create new blocks - I simply get a blank page. But the Index action is never called. Why doesn't this work? I am completely out of ideas, so if anyone got any suggestions, I would really appriciate it!