开发者

mcts mvc question [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment开发者_高级运维 in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

You are developing an ASP.NET MVC 2 Web application. The application contains a controller named HomeController, which has an action named Index. The application also contains a separate area named Blog. A view within the Blog area must contain an ActionLink that will link to the Index action of the HomeController. You need to ensure that the ActionLink in the Blog area links to the Index action of the HomeController. Which ActionLink should you use?

A. Html.ActionLink("Home", "Index", "Home")

B. Html.ActionLink("Home", "Index", "Home", new {area = ""}, null)

C. Html.ActionLink("Home", "Index", "Home", new {area = "Blog"}, null)

D. Html.ActionLink("Home", "Index", "Home", new {area = "Home"}, null)


I believe it is B.

A. Html.ActionLink("Home", "Index", "Home")

If you're inside the Blog area, it will look for a Home/Index within the Blog Area.

B. Html.ActionLink("Home", "Index", "Home", new {area = ""}, null)

This will specify that there is no area, and that it should look at the root of the application rather than a specific area.

C. Html.ActionLink("Home", "Index", "Home", new {area = "Blog"}, null)

Again, Home/Index is not in the blog area.

D. Html.ActionLink("Home", "Index", "Home", new {area = "Home"}, null)

There is no area called "Home".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜