Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When I test your route and the RedirectToAction(), it works correctly when I correct the case of the "CompanyId" property in the anonymous object to "companyId".</p> <pre><code>return RedirectToAction("Directives", "Project", new { projectId = 48, machineName = "Netduino", companyId = 27 }); </code></pre> <p>Update: Here is the code in global.asax, the Controllers, and the View.</p> <pre><code>routes.MapRoute( "Project", // Route name "{Controller}/{Action}/{projectId}/{machineName}/{companyId}", new { controller = "Project", action = "Directives", projectId = 0, machineName = "", companyId = 0 } // Parameter defaults ); public class HomeController : Controller { public ActionResult Index() { return RedirectToAction("Directives", "Project", new { projectId = 48, machineName = "Netduino", companyId = 27 }); } } public class ProjectController : Controller { public ActionResult Directives(int projectId, string machineName, int companyId) { ViewBag.ProjectId = projectId; ViewBag.MachineName = machineName; ViewBag.CompanyId = companyId; return View(); } } &lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;dynamic&gt;" %&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt; Directives &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;h2&gt; Directives&lt;/h2&gt; &lt;%: ViewBag.ProjectId %&gt;&lt;br /&gt; &lt;%: ViewBag.MachineName %&gt;&lt;br /&gt; &lt;%: ViewBag.CompanyId %&gt;&lt;br /&gt; &lt;%: this.Request.RawUrl %&gt; &lt;/asp:Content&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload