views:

21

answers:

2

The following returns "/Settings"

Url.Action("Index", "Settings");

On my local this renders fine. However on my remote machine I get the error belows. I get the impression that the controller is not properly instantiated.

Parser Error Message: Could not load type 'System.Web.Mvc.ViewPage<EStore.Domain.ViewModel.SettingsViewModel>'.    

Line 1:  <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<EStore.Domain.ViewModel.SettingsViewModel>" %>

Global.asax

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = "" }
);

routes.MapRoute(
    "AdminCompany",
    "{controller}/{action}/{companyId}/{id}",
    new { controller = "Home", action = "Index", companyId = "", id = "" }
);

routes.MapRoute(
    "Status",
    "{controller}/{action}/{id}/{statusId}",
    new { controller = "Home", action = "Index", id = "", statusId = ""}
);

routes.MapRoute(
    "Admin",
    "admin/{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = "" }
);

Index Actions

public ActionResult Index()
{
    var viewModel = IndexViewModel();
    return View(viewModel);
}
+1  A: 

It seems that the type loader cannot find the EStore.Domain.ViewModel.SettingsViewModel class. Make sure this class is included in one of the assemblies in the bin folder.

Darin Dimitrov
hi darin, to clarify. "Settings/Index" works. If just that "Settings/" doesn't seem to instantiated the controller.
frosty
to expand, i know EStore.Domain.ViewModel.SettingsViewModel is included in the assembly as "Setting/Index" works. How does the MVC framework know to look in "Index" action if no action is specified.
frosty
A: 
public ActionResult Index()
{
    var viewModel = IndexViewModel();
    return View(viewModel);
}

Should that read var ViewModel = new IndexViewModel();

seems like you might be passing a null through.

Also, where is the route for settings? Is it meant to pick up from the default route using the home controller?

Simon Hazelton
IndexviewModel is actually a method, this works fine. I believe setting would just use the first route. Weird that it works locally.
frosty