Override Index action

Feb 26, 2010 at 4:10 PM

 

I am trying to override the index method from my ocntroler to provide authentication.

i doesn;t like the default type:

System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[dbman_jQgrid.Models.RetiredProduct]' but this dictionary requires a model item of type 'dbman_jQgrid.Models.retProdGrid'.

public class ProductsController : MvcGridRepositoryCrudController<int, RetiredProduct, productRepository, retProdGrid>
    {
        public override ActionResult Index()
        {
            if (User.IsInRole(@"DBMAN-productsAdmin"))
            {
                return View("Index", AllItems());
            }
            else
            {
                TempData["Error"] = "<ul class='error'><li>You don't have the sufficient acces rights</li></ul>";
                return View("../Home/Index");
            }

        }

}

All others are working fine. Any clues on what canbe done to set right.

 

Feb 26, 2010 at 4:11 PM

I already found the solutions. I was not looking int he right direction.

//return View("Index", AllItems());
                ViewData.Model = new retProdGrid();
                return View("Index");

Thanks,