I have this actionresult method:
public ActionResult MenuItemCreated(MenuItem item)
{
return View(item);
}
And this is my view:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MenuItem>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
MenuItemCreated
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>MenuItemCreated</h2>
<%: Model.Caption %> is created succesfully
</asp:Content>
What I see on the page is correct (test is created successfully). But my querystring looks like this:
http://localhost:62602/Admin/MenuItemCreated/2?Caption=test&Link=%2Fclient
EDIT: The ActionResult is called from this method:
public ActionResult CreateMenuItem(FormCollection fc)
{
MenuItem menuItem = CreateMenuItemFrom(fc);
SaveMenuItem(menuItem);
return RedirectToAction("MenuItemCreated", menuItem);
}
EDIT II:
Corresponding view:
<% using (Html.BeginForm("CreateMenuItem","Admin",FormMethod.Post)) {%>
<%: Html.ValidationSummary(true) %>
<fieldset>
<legend>Fields</legend>
<div class="editor-label">
<%: Html.LabelFor(model => model.Caption) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Caption) %>
<%: Html.ValidationMessageFor(model => model.Caption) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.Link) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Link) %>
<%: Html.ValidationMessageFor(model => model.Link) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(model => model.ParentId) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.ParentId) %>
<%: Html.ValidationMessageFor(model => model.ParentId) %>
</div>
<p>
<input type="submit" value="Create MenuItem" />
</p>
</fieldset>
<% } %>
Why is this? I don't want the querystring to be shown.