Create a new asp.net mvc2 application. In the Home controller add this method:
public ActionResult Test(string id)
{
ViewData["Message"] = id;
return View();
}
Right click in the method and Add View.
View will be very simple:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Test
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Test</h2>
<h2><%: ViewData["Message"] %></h2>
</asp:Content>
In the master page, add this menu item:
<li><%: Html.ActionLink("Test", "Test", "Home") %></li>
Run the application. When the index page comes up, the “Test” menu item will correctly output as something like: http://localhost:60239/Home/Test
Add something to the end of the url, say “HelloWorld” and the url of the menu item holds the “HelloWorld” (http://localhost:60239/Home/Test/HelloWorld) rather than reverting back to http://localhost:60239/Home/Test like I would expect. Bug? Or am I missing something?
Technorati Tags:
asp.net mvc