RSS 2.0
# Monday, August 02, 2010

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:
Monday, August 02, 2010 1:15:09 AM UTC  #    Comments [0] -
mvc
Archive
<August 2010>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
George Handlin
Sign In
Statistics
Total Posts: 51
This Year: 0
This Month: 0
This Week: 0
Comments: 9
All Content © 2012, George Handlin
DasBlog theme 'Business' created by Christoph De Baene (delarou)