开发者

MVC3 actionlink

开发者 https://www.devze.com 2023-03-10 23:11 出处:网络
in MVC3 I have an area called test with a default route context.MapRoute( \"test_default\", \"test/{controller}/{action}/{id}\",

in MVC3 I have an area called test with a default route

        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") generates localhost:1111/test

In the index page I have a partial view, located in the folder test/views/shared But it's never rendererd because the folder is not found.

The link http://localhost:1111/test/store/index works well. How could I get the partial view found and rendered for the http:/localhost:1111/test? or how can I get the link http://lo开发者_如何学编程calhost:1111/test/Store/index generated by the actionlink?

thanks


It looks like you're changing your namespace argument to something outside the Area. If you have a test area, your route might look something like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号