Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4233880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:16:38+00:00 2026-05-21T02:16:38+00:00

I have this actionresult method: public ActionResult MenuItemCreated(MenuItem item) { return View(item); } And

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:16:38+00:00Added an answer on May 21, 2026 at 2:16 am

    The problem is the following line:

    return RedirectToAction("MenuItemCreated", menuItem);
    

    You cannot pass complex objects like this when you perform a redirect. Only simple scalar properties:

    return RedirectToAction("MenuItemCreated", new {
        id = menuItem.Id
    });
    

    and then inside the action you are redirecting to fetch the corresponding menu item model given the id:

    public ActionResult MenuItemCreated(int id)
    {
        var menuItem = _someRepository.GetMenuItem(id);
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this action method: [HttpPost] public ActionResult GetNextImage(int m_id) { ... return Json(new{...});
I have this controller method: public ActionResult Index(string searchError) { // get all errors
I have this action method in C#: public ActionResult Index() { ViewBag.Message = Hello;
I have this: public ActionResult GetBear(int bearId) { return Json(bear); } Here is the
I have this in HomeController : public ActionResult Details(string id) { var customer =
I have some code like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Save([Bind(Prefix=)]Person person) { String s
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
I have a controller method: public ActionResult Details(int id) { Order order = OrderFacade.Instance.Load(id);
I have this in my controller public ActionResult Testing() { CustomerContactModel model = new
I have this code in my view to hit one ActionResult ClearFilters = function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.