November Happy Hour will be moved to Thursday December 5th.

ActionResult index parameter is always null

Vote:
 

Hi everyone

We just started to work on a brand new epi7 site and it's a whole lot of fun.

But every page that we're making just returns null in the ActionResult index parameter. All except the startpage, which leads me to think that something's wrong with the routing. But that's just a guess.

This is how one of our controllers look like

 

public class ArticlePageController : BaseController<ArticlePage>
{
private IContentRepository _contentRepository;

public ArticlePageController(IContentRepository contentRepository)
{
_contentRepository = contentRepository;
}

public ArticlePageController()
{

}

public ActionResult Index(ArticlePage articlePage)
{
var model = new ArticlePageModel
{
Heading = articlePage.Heading,
MainBody = articlePage.MainBody
};
return View(model);
}

}

 

We have a View aswell and there's no typos nor anything.

 

But everytime we run a page we get "articlePage is null", or whatever page we try to run. All except startpage.

 

I'm sure the solution is dead simple but I'm all out of ideas :) Thanx in advance

#63049
Nov 07, 2012 20:55
Vote:
 

The modelbinder API uses names of parameters to decide if a certain model binder should handle the parameter, EPiServer will bind content parameters named "currentPage", "currentContent" and "currentBlock". So in your case name the parameter in Index method to any of those and the model binder will bind data to the parameter. 

#63050
Nov 07, 2012 21:08
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.