Alexey Kulikov
Alexey Kulikov

Reputation: 1147

Exception while using Html.Action in Asp.net mvc

Few words about a project. There are the Main web application (asp.net mvc) and "plugins". Plugin is a asp.net mvc project contains controllers and views. I am using RazorGenerator to make it works. Im Home view using this link:

<li>@Html.ActionLink("User Workspace", "Index", "Workspace/Workspace")</li>

it calls WorkspaceController from my UserWorkspace assembly (Workspace area). It works correctly. Workspace view contains:

@{
    ViewBag.Title = "Workspace";
}

<h2>User worspace</h2>
<div>
    TreePlugin:<br />
    @{
        Html.Action("Index", "Plugins/GeObjectTree"); // without this code works fine
    }
</div>

I need to render in workspace a plugin's view calling GeObjectTreeController (Plugins area) but this code raise an exception.

The controller for path '/Workspace/Workspace' was not found or does not implement IController.

Probably exception rises becouse GeObjectTreeController placed in another assembly? Or may be I need to configure some routes or namespaces? Thanks!

Upvotes: 0

Views: 285

Answers (2)

user3263194
user3263194

Reputation: 453

Try to use as shown below

<li>@Html.ActionLink("User Workspace", "Index", "Workspace",  new { area = "Workspace"}, null )</li>

Html.Action("Index", "GeObjectTree",  new {area = "Plugins"}, null)

Upvotes: 0

markpsmith
markpsmith

Reputation: 4918

Try this:

Html.Action("Index", "GeObjectTree", new {area = "Plugins"} )

Upvotes: 1

Related Questions