Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC -- Impersonate a Form POST
    text
    copied!<p>I have created an MVC application that dynamically routes actions and controllers based on user data, so that there are no standard actions, but dynamically named actions.</p> <p>In order to route the controller and action correctly, every route must go through a centralized Index which determines if the user has gone to a valid System in this case. i.e.</p> <pre><code>http://mysite.com/Systems/SystemName/RenameSystem </code></pre> <p>...where <strong>SystemName</strong> is the dynamic system name and <strong>RenameSystem</strong> is the action.</p> <p>Once a system has been routed correctly to the RenameSystem controller, the user is prompted with a textbox that allows them to change the system name. When submit is clicked, the form is routed back to my original Index Controller </p> <pre><code>public ActionResult Index(string systemName, string action) </code></pre> <p>instead of the standard </p> <pre><code>public ActionResult RenameSystem(string systemName) </code></pre> <p>I have placed in logic to determine if the RequestType is a POST or a GET. If the RequestType is a POST, the logic deviates and can capture the Form data contained in the request object. </p> <p>My question is, how can I take that Form data, which contains my systemName field and route it so that I don't need to throw data into a switch statement. i.e. I DO NOT want to do this:</p> <pre><code>switch case(action) { case "RenameSystem": return RenameSystem(Request.Form["systemName"]); } </code></pre> <p>and that I can dynamically POST to the standard:</p> <pre><code>public ActionResult RenameSystem(string systemName) </code></pre> <p>...simply by impersonating the calling View.</p> <p>Simply put I would like to be able to take the action, <strong>RenameSystem</strong> and call it so that my systemName will automatically fall into the systemName parameter of RenameSystem.</p> <p>Is this possible or are there any other choices on how to achieve this?</p> <p>Thanks, George </p>
 

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