This project is read-only.

Error 404 after build module

Topics: Writing modules
Sep 6, 2012 at 5:57 AM


I created module via codegen:

codegen module Test

I created Routes.cs:

using Orchard.Mvc.Routes;
using System.Web.Routing;
using System.Web.Mvc;
using System.Collections.Generic;

namespace Test
    public class Routes : IRouteProvider
        public void GetRoutes(ICollection<RouteDescriptor> routes)
            foreach (var routeDescriptor in GetRoutes()) 

        public IEnumerable<RouteDescriptor> GetRoutes()
            return new[] {
                new RouteDescriptor {
                    Route = new Route(
                        new RouteValueDictionary {
                            {"area", "Test"},
                            {"controller", "Test"},
                            {"action", "Index"}
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "Test"}
                        new MvcRouteHandler())

I created Index.cshtml in View folder:


I created simple controller:

using Orchard.Themes;
using System.Web.Mvc;

namespace Test.Controllers
    public class TestController : Controller
        public ActionResult Index()
            return View();

After this I  enabled module and create custom link ~/Test in Navigation.

Therefore localhost:8888/Test works fine when bin folder of module is empty

BUT. If I build my module Test. I got error: 

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Test

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

In source of page I see

  [HttpException]: The controller for path &#39;/Test&#39; was not found or does not implement IController.
  at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
  at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
  at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
  at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<BeginProcessRequest>b__2()
  at System.Web.Mvc.SecurityUtil.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a()
  at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[TResult](Func`1 func)
  at Orchard.Mvc.Routes.ShellRoute.HttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) in c:\Build\Orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:line 142
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Please help.

Sep 7, 2012 at 12:20 PM

I created virtual PC with windiws 2008r2. Install orchard and VS2010... and It works fine when I build module or no.

Sep 19, 2012 at 4:38 AM

I solved problem. The problem is appear when I'm using web platform installer for Orchard. Also it installs MVC 4 (System.Web.Mvc.dll version But System.Web.Mvc.dll (version 3.0.20105.0) exists in bin folder of orchard. The interface IController is defined in both. So, when I builded module, it's using latest version of System.Web.Mvc.dll. And we have error - version conflict. Need delete reference in module and using System.Web.Mvc.dll from bin folder of Orchard.