0

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

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

hi darin, to clarify. "Settings/Index" works. If just that "Settings/" doesn't seem to instantiated the controller.
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.
0
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?

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.