Orchard CMS中的控制器重定向

时间:2013-12-13 09:54:49

标签: asp.net-mvc-4 orchardcms

我有一个Orchard解决方案,其中添加了新模块。后来,我相应地添加了2个控制器及其视图。它们被命名为HomeController和SearchController。

在Home controller Index post方法中,我有一个调用SearchController Index操作方法的功能。但是,当我尝试执行代码时,我遇到了奇怪的错误,An exception was thrown while invoking the constructor 'Void .ctor()' on type 'SearchController'. ---> Object reference not set to an instance of an object. (See inner exception for details.)

HomeController代码

[ValidateAntiForgeryToken]
    [HttpPost]
    public ActionResult Index(FormCollection form)
    {
      return RedirectToAction("Index", "Search", new { area = "OPACCMS", srchtext = searchterm, sorting = sortby });
    }

SearchController代码

public ActionResult Index(string srchtext, string sorting, string Paging)
  {
    return View();
  }

路线代码

public class Routes : IRouteProvider
{
    public void GetRoutes(ICollection<RouteDescriptor> routes)
    {
        foreach (var routeDescriptor in GetRoutes())
            routes.Add(routeDescriptor);
    }

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

    }
}

对此问题的任何帮助都将受到高度赞赏。

由于

0 个答案:

没有答案