Reputation: 83
I'm trying to create a block in Episerver but got an error for the name of my class in the controller. The errormessage is
The type 'MyEpiserverSite.Controllers.WeekletterController' cannot be used as type parameter 'TBlockData' in the generic type or method 'BlockController'. There is no implicit reference conversion from 'MyEpiserverSite.Controllers.WeekletterController' to'EPIServer.Core.BlockData'
My code is
using EPiServer.Web.Mvc;
using EpiserverSite1.Models.Blocks;
using System.Web.Mvc;
namespace MyEpiserverSite.Controllers
{
public class WeekletterController : BlockController<WeekletterController>
{
public override ActionResult Index(WeekletterBlock currentblock)
{
return PartialView(currentblock);
}
}
}
Is there any using that I am missing or what are wrong whit my code?
Upvotes: 0
Views: 158
Reputation: 1027
You should try to avoid controllers for blocks, unless they are really necessary, i.e. you need to have business logic between the block data and the view.
Upvotes: 0
Reputation: 857
You inherit from BlockController<WeekletterController>
but you should inherit from BlockController<WeekletterBlock>
.
Upvotes: 3