MVC3 actionlink

时间:2011-06-06 13:35:53

标签: asp.net-mvc html.actionlink

在MVC3中我有一个名为test的区域,默认路由

        context.MapRoute(
            "test_default",
            "test/{controller}/{action}/{id}",
            new {controller="Store", action = "Index", id = UrlParameter.Optional },
            new string[] { "foo.test.Controllers" }
        );

@ Html.ActionLink(“Retour au magasin”,“index”,“Store”)生成localhost:1111 / test

在索引页面中,我有一个局部视图,位于文件夹test / views / shared中 但它永远不会渲染,因为找不到该文件夹​​。

链接http://localhost:1111/test/store/index效果很好。 我怎样才能获得为http:/ localhost:1111 / test找到并呈现的局部视图?或者我如何获得actionlink生成的链接http://localhost:1111/test/Store/index

感谢

1 个答案:

答案 0 :(得分:0)

看起来您正在将命名空间参数更改为Area之外的某些内容。如果您有测试区域,您的路线可能如下所示:

    context.MapRoute(
        "test_default",
        "test/{controller}/{action}/{id}",
        new {controller="Store", action = "Index", id = UrlParameter.Optional },
        new string[] { "MyWebProject.Areas.Test.Controllers" }
    );
相关问题