mvc索引动作无法呈现

时间:2010-08-18 11:14:54

标签: asp.net-mvc-2

以下内容返回“/ Settings”

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

在我当地,这很好。但是在我的远程计算机上,我得到以下错误。我得到的印象是控制器没有正确实例化。

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 = "" }
);

索引操作

public ActionResult Index()
{
    var viewModel = IndexViewModel();
    return View(viewModel);
}

2 个答案:

答案 0 :(得分:1)

似乎类型加载器找不到EStore.Domain.ViewModel.SettingsViewModel类。确保此类包含在bin文件夹中的一个程序集中。

答案 1 :(得分:0)

public ActionResult Index()
{
    var viewModel = IndexViewModel();
    return View(viewModel);
}

应该读取var ViewModel = new IndexViewModel();

好像你可能正在通过null。

此外,设置路线在哪里?它是否意味着使用家庭控制器从默认路由中选择?