PsychoCoder
PsychoCoder

Reputation: 10755

The IControllerFactory ... did not return a controller for the name 'Rss'

I have a Controller named RssController which looke like so

public partial class RssController : MVCExceptionBaseController
{

    public virtual ActionResult Display()
    {
        var viewModel = new RssList();
        return PartialView("Display", viewModel);
    }
}

When I click on the Log In link in my navigation I get the following message:

The IControllerFactory 'GodsCreationTaxidermy.Helpers.StructureMapControllerFactory' did not return a controller for the name 'Rss'.

The RSS is called from Site.Mater like so:

<% Html.RenderAction("Display", "Rss");%>

Display is a partial class which is used to display the Rss feed and it looks like this:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<ul>
<%  
    RssList viewModel = ViewData.Model as RssList;

    if (viewModel.Feeds.Count() > 0)
    {
        foreach (SelectListItem item in viewModel.Feeds)
        { %>
        <li>
            <%
              Response.Write(String.Format("<a href='{0}' target='_blank'>{1}  More</a>", item.Value, item.Text.TruncateString(30)));
            }%>
        </li>
    <% }%>
 </ul>

Any other links I click work fine, except Login (LogIn is in it's own area, could this be causing the issue, if so how would I go about resolving it?)

Upvotes: 4

Views: 19537

Answers (2)

isopropanol
isopropanol

Reputation: 1

I want to add a comment, partially for my own benefit, for when I run into this issue again.

Whatever framework you're using to do code/object injection might have a typo.

In my case, using Spring.net, I have a reference underneath the object trying to inject an object (a reference) that didn't exist.

I was good enough to have logging that indicated the neighborhood that a problem was happening, but the screen only gave the error above, that looks like "Controller not found" rather than "Can't resolve reference to object X while setting property Y".

While not what the OP needed it may help others.

Upvotes: 0

Andy Wilson
Andy Wilson

Reputation: 1383

By default, the Html.RenderAction method won't search for controllers outside the current area. In order for a controller inside the LogIn area to find the Rss controller, you need to use one of the overloads of the RenderAction method:

<% Html.RenderAction("Display", "Rss", new { area = "" }); %>

The "empty string" area is a container for any controller that isn't part of an area.

Upvotes: 8

Related Questions