1

我是 FubuMvc 的新手,我只是在一个小项目上玩弄它。

我有默认的 nuget 包 fubu 配置,并且我正在使用 Web 表单视图引擎:

    public ConfigureFubuMVC()
    {
        // This line turns on the basic diagnostics and request tracing
        IncludeDiagnostics(true);

        // All public methods from concrete classes ending in "Controller"
        // in this assembly are assumed to be action methods
        Actions.IncludeClassesSuffixedWithController();

        // Policies
        Routes
            .IgnoreControllerNamesEntirely().IgnoreControllerFolderName()
            .IgnoreMethodSuffix("Html")
            .RootAtAssemblyNamespace();

        // Match views to action methods by matching
        // on model type, view name, and namespace
        Views.TryToAttachWithDefaultConventions();

        // View Engine
        this.Import<WebFormsEngine>();
    }

我在站点根目录中创建了一个控制器和一个视图,如下所示:~/IndexController.cs

namespace MovieApp
{
public class IndexController
{
    private MoviesDBEntities _db = new MoviesDBEntities();

    public MovieIndexViewModel Index()
    {
        return new MovieIndexViewModel { Movies = _db.Movies.ToList() };
    }

    public class MovieIndexViewModel
    {
        public IEnumerable<Movie> Movies { get; set; }
    }
}
}

以及随之而来的视图:~/Index.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" MasterPageFile="/Site.Master" Inherits="MovieApp.Index" %>
...

当我浏览到 ~/Index 时,它工作正常。

现在我想将我的控制器移动到一个新文件夹“电影”中。所以我移动了控制器和视图,并将控制器上的命名空间更改为 MoviesApp.Movies。当我导航到 ~/Movies/Index 时,它在我的 IndexController.Index() ActionMethod 中遇到断点,但随后显示 404。

有任何想法吗?

4

1 回答 1

4

I assume that you're using the WebForms engine, right? For WebForms view resolution, FubuMVC makes the assumption that the namespace of the view exactly matches the view location. When you moved the views around those two things no longer match. If you've got R# installed, just open the code behind and have it adjust the Namespace -- and make sure the namespace gets changed on the aspx as well.

The better advice is probably to switch to the Spark view engine or Razor support in FubuMVC is already in flight.

于 2012-01-21T18:34:26.097 回答