Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Help with MVC controller in separate project #1547


User avatar
0
pszatkowski created

I'm sure this is something obvious I'm missing but I'm having real trouble getting an MVC controller in a separate project to work correctly.

My controller is defined as follows:

[DependsOn(typeof(AbpWebMvcModule))]
    public class SwiftSearchController : AbpController
    {
        public ActionResult Index()
        {
            return View();
        }
    }

The web project references this separate controller and the MVC routing seems to be working because when I browse to <a class="postlink" href="http://localhost/Mpa/SwiftSearch">http://localhost/Mpa/SwiftSearch</a> I receive the following error:

No component for supporting the service CMA.Zeus.Modules.SwiftSearchController was found

This is obviously some sort of DI issue but I'm struggling to solve it. Is there an example project for creating MVC controller in external assemblies?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you defined your controller in a seperate module, the seperate module should have a modue class defined like "YourCustomModule", and it should call

    IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
    

    in it's Initialize method.

    Then your web module should depend on your custom module.

    [...]
    [YourCustomModule]
    [...]
    public class YourWebModule : AbpModule
    {
        ...
    }